vb.net里面出现不支持data source关键字
Imports System.Data
Imports System.Data.SqlClient
Public Class Form1
Shared link As String = "data sourse=.;initial catalog=telephone;integrated security=true"
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim linking As New SqlConnection
linking.ConnectionString = link
Dim mycommand As SqlCommand = linking.CreateCommand
mycommand.CommandText = "insert into load(phone)value(@phone)"
mycommand.Parameters.Add("@phone", SqlDbType.Int, 4)
If Val(txtphone.Text) < 11111111 Or Val(txtphone.Text) > 99999999 Then
MsgBox("没有此号码!")
txtphone.Clear()
End If
mycommand.Parameters("@phone").Value = Val(txtphone.Text)
linking.Open()
mycommand.ExecuteNonQuery()
linking.Close()
Me.Close()
Form2.Show()
End Sub
End Class
调试的时候老说不支持data source 关键字
[解决办法]
- VB.NET code
Shared link As String = "data [color=#FF0000]sourse[/color]=.;initial catalog=telephone;integrated security=true"