Hi all,
i want to show my data in datagridview according to the SQL select stament with some condition.
Eg: in a table of stock will be classify with softwar and hardware, when a user login from hardware department then the datagridview will on display those stock under hardware, instead of show both software and hardware stock.
here is the code so far what i had but is not working:
Any idea??
thanks in advance!
i want to show my data in datagridview according to the SQL select stament with some condition.
Eg: in a table of stock will be classify with softwar and hardware, when a user login from hardware department then the datagridview will on display those stock under hardware, instead of show both software and hardware stock.
here is the code so far what i had but is not working:
VB.NET:
Dim conn As New SqlClient.SqlConnection
With conn
.ConnectionString = "SERVER = ; DATABASE = ; UID = root; PASSWORD = "
.Open()
End With
Dim cmd As New SqlClient.SqlCommand
With cmd
If Form_FPCOSTM003S.Label_Machine_Code.Text = "BAH1" Or Form_FPCOSTM003S.Label_Machine_Code.Text = "SG1" Then
.CommandText = "SELECT * FROM Machine_Material_Data WHERE Mac_Mcode = '" & Form_FPCOSTM003S.Label_Machine_Code.Text.Trim & "' AND Mac_MatTypeCode = 'GLUE' ORDER BY Mac_MCode"
.Connection = conn
Else
.CommandText = "SELECT * FROM Machine_Material_Data WHERE Mac_Mcode = '" & Form_FPCOSTM003S.Label_Machine_Code.Text & "' ORDER BY Mac_MCode"
End If
End With
thanks in advance!