Question Visual Basic.NET with SQL help!

JayWalker

Member
Joined
Jun 20, 2011
Messages
15
Programming Experience
Beginner
Hello everyone :)

Okay, first off I'm kinda new to programming. Still in the learning phase. :) Started by learning some VB.NET. I've been creating this little program. It's a school/institute managment system kind of a thing. not very cool though. hehe..

Anyways, I'm having a little trouble with the search module which I created to find students that are in the database.

Here's the code I've written so far.

code.png

I have debugged the code and the SQL statement executes perfectly. But the data doesn't show up in the grid!

form design.png

Please if anyone could help me out with this, it'll be more than appreciated.

Thanks in advance.

I.J
 
May I ask why you are adding DataAdapters in the designer? You can if you want but it doesn't really make sense to these days. If you really want to set up your data access in the designer then there are better ways these days.

To answer your question specifically, I think that it's safe to say that you haven't bound the grid to the data. You would need the set the DataSource and DataMember.
 
****! I completely forgot to do that!! oh man, I'm such an idiot! I'll fix it up now. Thank you so much :)

well, using data adapters is the only way I know. If you could tell me a few alternatives, I'll look em up for sure. :)
 
With VB 2005 came the Data Source wizard. You can create a new Data Source from the Data menu. Once you have stepped through the wizard, you'll have a typed DataSet, complete with TableAdapters. The DataAdapters and Connections are hidden inside the TableAdapters, making your life easier. You can then drag tables and/or columns from the Data Sources window onto your form, which will add the appropriate objects and setup all the bindings for you. In this case, dragging a table onto the form would add a DataSet, TableAdapter, DataGridView, BindingSource and BindingNavigator, plus add all the bindings as well as some basic retrieval and saving code.

The Data Source wizard doesn't just support typed DataSets either, so you could also generate an Entity Framework model. That is even easier to work with than a typed DataSet, although you need to learn some LINQ to use it effectively.
 
Back
Top