我在输入乘法输入时遇到问题
Try
Dim StrSQL As String = "INSERT INTO boranga" & _
"(IdBorangA,Answers)" & _
"VALUES (@B_IdA,@B_Answer);"
Dim myCommand As MySqlCommand = New MySqlCommand(StrSQL, conn.open)
myCommand.CommandType = CommandType.Text
Dim parameterB_IdA As MySqlParameter = New MySqlParameter("@B_IdA", MySqlDbType.VarChar, 300)
parameterB_IdA.Value = Label1.Text
Dim parameterB_Answer As MySqlParameter = New MySqlParameter("@B_Answer", MySqlDbType.VarChar, 300)
parameterB_Answer.Value = TextBox1.Text
With myCommand.Parameters
.Add(parameterB_IdA)
.Add(parameterB_Answer)
End With
Dim result As MySqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
MsgBox("Tersimpan", vbYes, "boranga")
Catch SqlEx As MySqlException
Throw New Exception(SqlEx.Message.ToString())
End Try
此当前代码用于为每个表“IdBorangA”和“Answer”只输入一个输入,我尝试稍微调整一下
Try
Dim StrSQL As String = "INSERT INTO boranga" & _
"(IdBorangA,Answers)" & _
"VALUES (@B_IdA,@B_Answer);"
Dim myCommand As MySqlCommand = New MySqlCommand(StrSQL, conn.open)
myCommand.CommandType = CommandType.Text
Dim parameterB_IdA As MySqlParameter = New MySqlParameter("@B_IdA", MySqlDbType.VarChar, 300)
parameterB_IdA.Value = Label1.Text
parameterB_IdA.Value = Label2.Text
Dim parameterB_Answer As MySqlParameter = New MySqlParameter("@B_Answer", MySqlDbType.VarChar, 300)
parameterB_Answer.Value = TextBox1.Text
parameterB_Answer.Value = TextBox2.Text
With myCommand.Parameters
.Add(parameterB_IdA)
.Add(parameterB_Answer)
End With
Dim result As MySqlDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
MsgBox("Tersimpan", vbYes, "boranga")
Catch SqlEx As MySqlException
Throw New Exception(SqlEx.Message.ToString())
End Try
通过为 IdBorangA 添加更多参数“parameterB_IdA.Value = Label1.Text”和为 Answer 添加更多参数“parameterB_Answer.Value = TextBox2.Text”
但我得到的结果是表格只填充了来自 Label2.text 和 Textbox2.text 的数据。
我不知道出了什么问题..如果你们有任何想法可以帮助我解决这个问题。随意回答:)