我有一個項目運行完美,即在代碼鏈接的數據庫中輸入值。但在我正在實施的其他項目中,它顯示正確提交的值,在運行時不會發生錯誤,但值不會輸入到數據庫中。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