Articles > Tutorials
Vb.net is a pretty cool programming language. It makes complicated tasks much easier than in previous languages. You can also do alot without writing tons of code. I hope the following tips will help you.
Datasets, SQL, and Data Grids
Working with SQL and data grids can be very useful. To start a project that works with SQL, start a new project and select Windows Application as the project type. Then add a data grid from the Toolbox area. Next drag a SQL adapter over from the toolbox area (on the left side). You'll have to click on "Data". Go through the SQL adapter wizard which will help you make a SQL connection.
Now depending on how you want to use this data a regular dataset may not be what you need. You may need to create a new class that defines a new type of dataset. To do this goto "Data > Generate Dataset" from the main menu (top of screen). This will create a data set based on your SQL table.
The SQL data adapter should be called something like "SQLdataAdapter1" and a simple SQL command should look like this:
SQLdataAdapter1.SelectCommand.CommandText = "SELECT db.table.* FROM db.table WHERE ColumnName='Value'"
Of couse that can be a long line of code, so you may like this better:
Dim strSQL as string
strSQL = "SELECT db.table.* FROM db.table WHERE ColumnName='Value'"
SQLdataAdapter1.SelectCommand.CommandText = strSQL
If you using a variable then it would be:
Dim strSQL as string
strSQL = "SELECT db.table.* FROM db.table WHERE ColumnName='" & strValue &"'"
SQLdataAdapter1.SelectCommand.CommandText = strSQL
Then you should save the result of this query to a dataset:
Dim dsData as Dataset
SQLdataAdapter1.Fill(dsData)
That command will save the SQL query results to a dataset named "dsData".
VB.Net Tips
Last Updated: 2/14/10Vb.net is a pretty cool programming language. It makes complicated tasks much easier than in previous languages. You can also do alot without writing tons of code. I hope the following tips will help you.
Datasets, SQL, and Data Grids
Working with SQL and data grids can be very useful. To start a project that works with SQL, start a new project and select Windows Application as the project type. Then add a data grid from the Toolbox area. Next drag a SQL adapter over from the toolbox area (on the left side). You'll have to click on "Data". Go through the SQL adapter wizard which will help you make a SQL connection.
Now depending on how you want to use this data a regular dataset may not be what you need. You may need to create a new class that defines a new type of dataset. To do this goto "Data > Generate Dataset" from the main menu (top of screen). This will create a data set based on your SQL table.
The SQL data adapter should be called something like "SQLdataAdapter1" and a simple SQL command should look like this:
SQLdataAdapter1.SelectCommand.CommandText = "SELECT db.table.* FROM db.table WHERE ColumnName='Value'"
Of couse that can be a long line of code, so you may like this better:
Dim strSQL as string
strSQL = "SELECT db.table.* FROM db.table WHERE ColumnName='Value'"
SQLdataAdapter1.SelectCommand.CommandText = strSQL
If you using a variable then it would be:
Dim strSQL as string
strSQL = "SELECT db.table.* FROM db.table WHERE ColumnName='" & strValue &"'"
SQLdataAdapter1.SelectCommand.CommandText = strSQL
Then you should save the result of this query to a dataset:
Dim dsData as Dataset
SQLdataAdapter1.Fill(dsData)
That command will save the SQL query results to a dataset named "dsData".
Keywords: dataset data set SQL connection database treeview tree view nodes creating parent and child nodes with relation selected node text hashtable records nodes array sort hashtable no sort datagrid data grid row column select with sql command vb_net