I have this program but when i debug i, dont know what the error is.
What im trying to do here is to pass a data from a Form(MainMenu) to a class(tableClass) to be process. From the MainMenu i assign Cust_table with 1, thats the integer shall be pass to tableClass.
Code:Dim Cust_table As New TableClass Cust_table.Table_No = 1
Upon receiving data from MainMenu form. If u can see, the blue code part
is working fine. But when it comes to If, else. It have this error
Must declare the scalar variable "@Cust_table".
TableClass code
My second question is, why can't i use CustTable in first part not the second part. Eventh thought it already been assign the parameter pass right.Code:Get Return Cust_table End Get Set(ByVal value) Cust_table = value Dim Conn As New SqlConnection("Data Source=ANNAS;Initial Catalog=RMS01;Integrated Security=True") Dim command As New SqlCommand("SELECT Counter FROM CounterMeja WHERE Meja = @Cust_table", Conn) Conn.Open() command.Parameters.AddWithValue("Cust_table", Cust_table) command.ExecuteScalar() If Counter = 0 Then Dim command2 As New SqlCommand("Update CounterMeja Set Counter = 1 Where Meja = @Cust_table", Conn) Command.Parameters.AddWithValue("Cust_table", Cust_table) command2.ExecuteNonQuery() OrderForm.Show() Else Dim Result As String Result = ("Sorry this table has already been occupied") End If Conn.Close()
thank U




Reply With Quote