vb.net 向数据库插入记录不行为什么?
Imports System.Data.OleDbPublic Class main
Private Sub main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Static cn As OleDbConnection
Static da As OleDbDataAdapter
Static ds As DataSet
Static cnStr As String
cnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\tools\MyFile\Assessment\Assessment\data.mdb;Persist Security Info=False"
cn = New OleDbConnection(cnStr)
Dim sql As String
sql = "select * from User_tbl"
da = New OleDbDataAdapter(sql, cn)
ds = New DataSet
da.Fill(ds, "User_tbl")
DataGridView1.DataSource = ds.Tables(0)
Static Name As String
Static pwd As String
Name = "sdfs"
pwd = "sdfs"
'cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\tools\MyFile\Assessment\Assessment\data.mdb;Persist Security Info=False")
cn.Open()
Static sd As String
sd = "insert into User_tbl (ID,name,pwd) values('" & "','" & Name & "','" & pwd & "'')"
Static cm = New OleDbCommand(sd, cn)
'cm.ExecuteNonQuery()
cn.Close()
MessageBox.Show("保存成功!!!")
End Sub
End Class
这是代码?