VB.NET中执行到这句cmd.ExecuteNonQuery()后显示至少有一个参数值没有被指定
ImportsSystem.DataImportsSystem.Data.OleDbPublicClassaUpdatePrivateSubButton1_Click(B...
Imports System.Data
Imports System.Data.OleDb
Public Class aUpdate
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" & Application.StartupPath & "\dbRNA.mdb"
Dim Conn As OleDbConnection = New OleDbConnection(strConn)
Conn.Open()
Dim Cmd As OleDbCommand = New OleDbCommand()
Cmd.Connection = Conn
Dim xaname, xafeature, xamolecular, xaisolectric, xacarboxy, xaamino, sqlJudge, sqlUpdate As String
xaname = TextBox1.Text
xafeature = TextBox2.Text
xamolecular = TextBox3.Text
xaisolectric = TextBox4.Text
xacarboxy = TextBox5.Text
xaamino = TextBox6.Text
sqlJudge = "select count(*) from tacid where aname='" & xaname & "'"
Cmd.CommandText = sqlJudge
Dim n As Integer
n = Integer.Parse(Cmd.ExecuteScalar().ToString())
If n = 1 Then
sqlUpdate = "update tacid SET afeature = '" & xafeature & "',amolecular='" & xamolecular & "',aisolectric='" & xaisolectric & ",acarboxy='" & xacarboxy & "',aamino='" & xaamino & "' where aName='" & xaname & "'"
Cmd.CommandText = sqlUpdate
Cmd.ExecuteNonQuery()
MsgBox("修改成功!")
Else
MsgBox("无记录,不能修改!")
End If
Conn.Close() 展开
Imports System.Data.OleDb
Public Class aUpdate
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" & Application.StartupPath & "\dbRNA.mdb"
Dim Conn As OleDbConnection = New OleDbConnection(strConn)
Conn.Open()
Dim Cmd As OleDbCommand = New OleDbCommand()
Cmd.Connection = Conn
Dim xaname, xafeature, xamolecular, xaisolectric, xacarboxy, xaamino, sqlJudge, sqlUpdate As String
xaname = TextBox1.Text
xafeature = TextBox2.Text
xamolecular = TextBox3.Text
xaisolectric = TextBox4.Text
xacarboxy = TextBox5.Text
xaamino = TextBox6.Text
sqlJudge = "select count(*) from tacid where aname='" & xaname & "'"
Cmd.CommandText = sqlJudge
Dim n As Integer
n = Integer.Parse(Cmd.ExecuteScalar().ToString())
If n = 1 Then
sqlUpdate = "update tacid SET afeature = '" & xafeature & "',amolecular='" & xamolecular & "',aisolectric='" & xaisolectric & ",acarboxy='" & xacarboxy & "',aamino='" & xaamino & "' where aName='" & xaname & "'"
Cmd.CommandText = sqlUpdate
Cmd.ExecuteNonQuery()
MsgBox("修改成功!")
Else
MsgBox("无记录,不能修改!")
End If
Conn.Close() 展开
1个回答
展开全部
sqlUpdate = "update tacid SET afeature = '" & xafeature & "',amolecular='" & xamolecular & "',aisolectric='" & xaisolectric & "',acarboxy='" & xacarboxy & "',aamino='" & xaamino & "' where aName='" & xaname & "'"
将sql语句换成这个,你之前写的有一个分号少了
将sql语句换成这个,你之前写的有一个分号少了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询