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