请问VB.NET和SQL数据库的这个连接怎么做?

在做一个VB.NET的作业,要求在后台数据库"students.mdb"中的表"学生"中通过SQL语句增加数据,请问该用什么代码?我从书上抄的代码用Visualstudi... 在做一个VB.NET的作业,要求在后台数据库"students.mdb"中的表"学生"中通过SQL语句增加数据,请问该用什么代码? 我从书上抄的代码用Visual studio2005编译能过,执行也能过,但是执行过后却没有对数据库有任何的影响(也就是说输不进去)我的代码如下,请高人帮帮忙啊: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim jidian As String jidian = (TextBox3.Text - "50" / "10") Dim strconn As String = "provider=Microsoft.jet.oledb.4.0;Data Source = students.mdb" Dim objconn As New OleDbConnection(strconn) Dim objadap As New OleDbDataAdapter() Dim objdset As New DataSet() Dim insertsql As String insertsql = "insert into " + ComboBox1.Text + "(姓名,学号,分数,绩点) values(" + "@" + TextBox1.Text + "," + "2" + TextBox2.Text + "," + "2" + TextBox3.Text + "," + "@" + jidian + ")" objconn.Open() objadap.SelectCommand = New OleDbCommand(insertsql, objconn) objconn.Close() objdset.Clear() MsgBox("导入成功", , "恭喜") End Sub 展开
 我来答
加东大介
2014-05-29 · TA获得超过1179个赞
知道小有建树答主
回答量:444
采纳率:58%
帮助的人:141万
展开全部
楼主式式把button的click的代码改成下面的成不成 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim jidian As String jidian = (TextBox3.Text - "50" / "10") Dim strconn As String = "provider=Microsoft.jet.oledb.4.0;Data Source = students.mdb" Dim objconn As New OleDbConnection(strconn) Dim insertsql As String insertsql = "insert into " + ComboBox1.Text + "(姓名,学号,分数,绩点) values(" + "@" + TextBox1.Text + "," + "2" + TextBox2.Text + "," + "2" + TextBox3.Text + "," + "@" + jidian + ")" Dim objcmd As New OleDbCommand(insertsql, objconn) objconn.Open() objcmd.ExecuteNonQuery() objconn.Close() MsgBox("导入成功", , "恭喜") End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式