vb访问mysql容易死机,致命错误期间遇到命令执行MySQL的VB

ijust finish my code for inserting data using the vb and mySQL but when i run my webpage it seem have an error Fatal Error Encounter During Command Execution . Please help some how to solve it. below is my code.

Imports System.Data.SqlClient

Imports MySql.Data.MySqlClient

Partial Class Request

Inherits System.Web.UI.Page

Dim MessageBox As Object

Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

txt1.Focus()

txt2.Focus()

txt3.Focus()

txt4.Focus()

txt5.Focus()

txt6.Focus()

txt7.Focus()

ddl1.Focus()

ddl2.Focus()

ddl3.Focus()

ddl4.Focus()

End Sub

Protected Sub btnsubmit_Click(sender As Object, e As EventArgs) Handles btnsubmit.Click

'Create sql connection and fetch data from database based on employee id

Dim conn As New MySql.Data.MySqlClient.MySqlConnection

Dim strConnectionString As String = ConfigurationManager.ConnectionStrings("testConnectionString").ConnectionString

Try

conn.ConnectionString = strConnectionString

conn.Open()

Catch ex As MySql.Data.MySqlClient.MySqlException

MessageBox.Show(ex.Message)

End Try

' Dim cr_id As String

' cr_id = "CR004"

Dim iReturn As Boolean

Using SQLConnection As New MySqlConnection(strConnectionString)

Using sqlCommand As New MySqlCommand()

sqlCommand.Connection = SQLConnection

With sqlCommand

.CommandText = "INSERT INTO cr_record(idcr_record,Emplid,Nama,date,DeptDesc,email,change,reasonchange,problem,priority,reasondescription,systemrequest) VALUES (@IDCR,@Emplid,@Nama,@date,@DeptDesc,'@email,@change,@reasonchange,@problem,@priority,@reasondescription,@systemrequest)"

' .CommandTimeout = 5000000

.CommandType = Data.CommandType.Text

.Parameters.AddWithValue("@Emplid", txt1.Text)

.Parameters.AddWithValue("@Nama", TextBox1.Text)

.Parameters.AddWithValue("@date", txt5.Text)

.Parameters.AddWithValue("@DeptDesc", txt2.Text)

.Parameters.AddWithValue("@email", txt4.Text)

.Parameters.AddWithValue("@change", ddl2.Text)

.Parameters.AddWithValue("@reasonchange", txt6.Text)

.Parameters.AddWithValue("@problem", ddl3.Text)

.Parameters.AddWithValue("@priority", rbl1.Text)

.Parameters.AddWithValue("@reasondescription", txt7.Text)

.Parameters.AddWithValue("@systemrequest", ddl4.Text)

End With

Try

SQLConnection.Open()

' sqlCommand.ExecuteNonQuery()

sqlCommand.ExecuteNonQuery()

iReturn = True

MsgBox("Added Successfully")

Catch ex As MySqlException

MsgBox(ex.Message.ToString & Err.Description)

iReturn = False

Finally

SQLConnection.Close()

End Try

End Using

End Using

Return

End Sub

End Class

解决方案

you probably forgot to add this parameter @IDCR

.Parameters.AddWithValue("@IDCR", toyourvariable)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值