HS Banner
Back
SQL Connection and Query

Author: b.henry 03/19/2021
Language: Visual Basic .NET
Tags: SQL connection vb.net


Description:

This is a SQL connection and query using the System.Data.SqlClient

Article:

The following example creates a SqlConnection, a SqlCommand, a SqlDataAdapter, fills a DataTable, and a for each as DataRow.

Using con As New SqlConnection("SQL Connection String")
         Using cmd As New SqlCommand("Select * from Settings", con)
             Using sda As New SqlDataAdapter(cmd)
                 Using dt As New DataTable()
                     sda.Fill(dt)
                     For Each row As DataRow In dt.Rows
                         TaxesLand = CDbl(row.Item("TaxesLand"))
                         TaxesImprovement = CDbl(row.Item("TaxesImprovement"))
                     Next row
                 End Using
             End Using
         End Using
End Using


Back
Comments
Add Comment
There are no comments yet.