This is driving me nuts... I can't seem to figure out what is wrong with this, I keep getting: Prepared statement '(@VendorID int)Select VI.VendorID, VI.DivisionName, VI.DeptName,' expects parameter @VendorID, which was not supplied. "
Any ideas???
Thanks
Code:
Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Define connection to read the data
Dim myConn As New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
Dim MyCmd As New SqlCommand("Select VI.VendorID, VI.DivisionName, VI.DeptName, VI.VendorCode, VI.VendorName, VI.Responsibility, VI.Joined, VI.SKU, VI.EDI, VI.RBT, VI.ContactName, VI.ContactPhone, VI.ContactFax, VI.EmailAddress, VS.Status From tblVendorInfo VI Join tblVendorComments VM On VI.VendorID = VM.VendorID Join tblVendorStatus VS On VI.CurrentStatus = VS.StatusID Where VendorID = @VendorID", myConn)
MyCmd.CommandType = CommandType.Text
MyCmd.Parameters.Add(New SqlParameter("@VendorID", SqlDbType.Int, 4)).Value = Convert.ToString(VendorID)
myConn.Open()
'Read the data
Dim Result As SqlDataReader = MyCmd.ExecuteReader(CommandBehavior.CloseConnection)
Result.Read()
VendorNumber.Text = Result("VendorID").ToString()
If Not Result.IsDBNull(0) Then
DivisionName.Text = Result("DivisonName").ToString()
End If
If Not Result.IsDBNull(0) Then
DeptName.Text = Result("DeptName").ToString()
End If
If Not Result.IsDBNull(0) Then
VendorName.Text = Result("VendorName").ToString()
End If
If Not Result.IsDBNull(0) Then
Joined.Text = Result("Joined").ToString()
End If
If Not Result.IsDBNull(0) Then
SKU.Text = Result("SKU").ToString()
End If
If Not Result.IsDBNull(0) Then
EDI.Text = Result("EDI").ToString()
End If
If Not Result.IsDBNull(0) Then
Rbt.Text = Result("RBT").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactName.Text = Result("ContactName").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactPhone.Text = Result("ContactPhone").ToString()
End If
If Not Result.IsDBNull(0) Then
ContactFax.Text = Result("ContactFax").ToString()
End If
If Not Result.IsDBNull(0) Then
EmailAddress.Text = Result("EmailAddress").ToString()
End If
If Not Result.IsDBNull(0) Then
Comment.Text = Result("Comment").ToString()
End If
myConn.Close()
End Sub
Any ideas???
Thanks