Skip to content
Advertisement

Displaying Data From Database With Vb.net with combobox

I face an error in my syntax which is indicating near the AND Operator

I created a class called displayTable to use command passed through the parameter to display into the datagridview

Advertisement

Answer

It is a good idea to divide the code into User Interface code that interacts with the controls on the form and data access code that interacts with the database.

The Using...End Using block takes care of closing and disposing the connection and command even if there is an error.

The use of Parameters protects your database from sql injection. I had to guess at the size of the class column. Check your database for the actual value.

.ExecuteNonQuery is for Insert, Update and Delete not Select. You can load a DataTable with a reader.

In the UI

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement