VB连接远程电脑数据库问题求助!
我在学VB,刚起步,菜鸟一个。我看百度上有人给出了VB连接远程电脑的程序,我整段复制到窗体命令编辑栏里面,这样对吗?计算机名我也改了,用户名我也改了,数据库也改了,但是运行后出现编译错误:缺少语句结束。这是怎么一回事呢?求大侠帮帮忙,我初来乍到,有点笨,还望指点。'定义一个数据库连接
Dim con As New SqlConnection("workstation id=计算机名;packet size=4096;user id=sa;data source=.;persist security info=False;initial catalog=数据库名")
'对数据库插入
Dim incom As New SqlCommand("insert into 表名values(@id,@name,@password,@depart,@class)", con)
incom.Parameters.Add("@id", Me.idtb.Text)
incom.Parameters.Add("@name", Me.nametb.Text)
incom.Parameters.Add("@password", Me.passwordtb.Text)
incom.Parameters.Add("@depart", Me.departtb.Text)
incom.Parameters.Add("@class", Me.classtb.Text)
con.Open()
incom.ExecuteNonQuery()
con.Close()
MsgBox ("insert good")
Me.DataGrid1.Refresh()
'删除数据库项
Dim deleteEMP As SqlClient.SqlCommand = New SqlClient.SqlCommand("delete from 表名 where 列名 = '" & checkcb.Text & "'", conn)
result = deleteEMP.ExecuteNonQuery()
conn.Close()
Me.DataGrid1.Refresh()
MsgBox ("delete good")
'对数据库更新
Dim upcom As New SqlCommand("update 表明set Stu_name=@name,Stu_password=@password,Stu_depart=@depart,Stu_class=@class where Stu_id=@id", con)
upcom.Parameters.Add("@id", Me.idtb.Text)
upcom.Parameters.Add("@name", Me.nametb.Text)
upcom.Parameters.Add("@password", Me.passwordtb.Text)
upcom.Parameters.Add("@depart", Me.departtb.Text)
upcom.Parameters.Add("@class", Me.classtb.Text)
con.Open()
upcom.ExecuteNonQuery()
con.Close()
MsgBox ("update good")