查询语句执行后,DATAGRID表中内容发生变化,说明关联性没问题
没有出现你要的结果的话,说明查询的SQL语句中的条件设置不正确
没有出现你要的结果的话,说明查询的SQL语句中的条件设置不正确
===================================================
讨厌C#的行尾的小尾巴;和一对大括号{ }
===================================================
Private Sub Command3_Click() sqlstr = "insert into stucourse " & "(course_id, student_id)" & _ "values(" & "'" & DataGrid1.Columns(0).Value & "'," & "'" & login.i & "');" conn.ConnectString = "Provider=SQLOLEDB.1;Password=sa;User ID=sa; Initial Catalog=StuData ;Data Source = 127.0.0.1" 错误在这里 conn.Open conn.Execute sqlstr conn.Close MsgBox "选课成功!", vbOKOnly + vbExclamation, "警告" End Sub