Must Declare Scalar Quantity @USERID

Posted by Cibin under VB.NET on 7/21/2013 | Points: 10 | Views : 1050 | Status : [Member] | Replies : 1
Hi,

I want to retrieve values from access database and insert in to sql database. The structure of tables in both databases are same. but when i inserting the data to sql db, I am getting this error ..... "Must Declare Scalar Quantity @USERID" ,,, Please anyone help me out from this error..

myconn.Open()
connString.Open()
sql = "SELECT * FROM CHECKINOUT WHERE CHECKTIME >= ? AND CHECKTIME <= ?"
Dim cmd As New OleDbCommand(sql, myconn)
cmd.CommandType = CommandType.Text
cmd.Parameters.AddWithValue("CHECKTIME", TextBox1.Text)
cmd.Parameters.AddWithValue("CHECKTIME", TextBox2.Text)
rd = cmd.ExecuteReader()



If rd.HasRows = True Then
While rd.Read()
Try
acc = "INSERT INTO CHECKINOUT VALUES (@USERID ,@CHECKTIME,@CHECKTYPE,@VERIFYCODE,@SENSORID,@WorkCode,@sn,@UserExtFmt)"
Dim cmd1 As New OleDbCommand(acc, connString)

cmd1.CommandType = CommandType.Text
cmd1.Parameters.AddWithValue("@USERID", SqlDbType.Int).Value = Val(rd.Item(0))
cmd1.Parameters.AddWithValue("@CHECKTIME", SqlDbType.DateTime).Value = Val(rd.Item(1))
cmd1.Parameters.AddWithValue("@CHECKTYPE", SqlDbType.VarChar).Value = rd.Item(2).ToString()
cmd1.Parameters.AddWithValue("@VERIFYCODE", SqlDbType.Int).Value = Val(rd.Item(3))
cmd1.Parameters.AddWithValue("@SENSORID", SqlDbType.Int).Value = rd.Item(4)
cmd1.Parameters.AddWithValue("@WorkCode", SqlDbType.VarChar).Value = rd.Item(5).ToString()
cmd1.Parameters.AddWithValue("@sn", SqlDbType.VarChar).Value = rd.Item(6).ToString()
cmd1.Parameters.AddWithValue("@UserExtFmt", SqlDbType.VarChar).Value = rd.Item(7).ToString()

cmd1.ExecuteNonQuery()

Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

End While
End If




Responses

Posted by: Cibin on: 7/22/2013 [Member] Starter | Points: 25

Up
0
Down
the data migration to SQL Server is easy using the SQL Server Migration wizard. Then you will have a working microsoft access application.... And also we can give a link with access database ,, so when we make any changes to the access db , then it will automatically make changes in the sql db ...

To Download Migration Wizard Use this link : http://www.microsoft.com/en-us/download/confirmation.aspx?id=28763

Cibin, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response