/ Published in: VB.NET
Easily populate VB.NET DataGridView with data from MSSQL Server Stored Procedure
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Imports System Imports System.Data Imports System.Data.SqlClient '... Dim constr As String _ = "User ID=<db_user>;Password=<db_password>;Initial Catalog=<database_name>;Data Source=(local)" Using con As New SqlConnection(constr) Using cmd As New SqlCommand("<stored_procedure_name>") cmd.Connection = con cmd.CommandType = CommandType.StoredProcedure cmd.Parameters.Add("@<param_1>", <value_1>) cmd.Parameters.Add("@<param_2>", <value_2>) cmd.Parameters.Add("@<param_3>", <value_3>) Using sda As New SqlDataAdapter(cmd) Dim dt As New DataTable() sda.Fill(dt) <data_grid_view_component_name>.DataSource = dt End Using End Using End Using