我有一个项目运行完美,即在代码链接的数据库中输入值。但在我正在实施的其他项目中,它显示正确提交的值,在运行时不会发生错误,但值不会输入到数据库中。VB.NET连接到SQL服务器
Private Sub frmAddresume_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
cn.ConnectionString = "Data Source=ROHAN-PC\SQLEXPRESS;initial catalog=Libeasy;Integrated Security=true"
DateTimePicker1.Value = DateTime.Now.ToShortDateString()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If (TextBox1.Text <> "" And TextBox2.Text <> "" And TextBox3.Text <> "") Then
cn.Open()
cmd.Connection = cn
cmd.CommandText = "insert into StudResume values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + DateTimePicker1.Value.ToShortDateString() + "'," + TextBox3.Text + ")"
cmd.Dispose()
cn.Close()
MsgBox("Details saved Successfully", MsgBoxStyle.Information, "Done")
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
DateTimePicker1.Value = Now
TextBox1.Focus()
Else
MsgBox("Please Enter Complete Details", MsgBoxStyle.Critical, "Error")
End If
End Sub
它给出错误sqlException是未注册的 – 2015-02-12 09:23:44
检查query.it可能是查询参数的问题。 – 2015-02-12 09:27:04
实际上,我有另一个项目的代码工作块像上面那样虽然那个工作 – 2015-02-12 09:28:50