Hi all,
i am trying to bring a query result as a datagrid. I am new to vb.net.
SQL 2005, Visual studio 2005
I have a sql query to display 3 cols of value. the below is my code
------------------------------------------------------------------------
Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConString As String = "Data Source=<>;Initial Catalog='<>';User Id=sa;Password=<>;"
Dim MyCon As New SqlConnection
MyCon.ConnectionString = ConString
Dim DA As New SqlDataAdapter("Select [No_], [Name], [City] from [dbo].[Customer]", MyCon)
Dim DS As New DataSet
DA.Fill(DS, "[dbo].[Customer]")
Dim DataGridView1 As New DataGridView
DataGridView1.DataSource = DS.DefaultViewManager
End Sub
-------------------------------------------------------
Kindly bear with my question.
What i did is at first i dint have a datagrid, drag n dropped in the form.
When executing the code the results not getting populated to the datagrid.
please guide me where im going wrong with the codings?
Many Thanks,
Meera.
i am trying to bring a query result as a datagrid. I am new to vb.net.
SQL 2005, Visual studio 2005
I have a sql query to display 3 cols of value. the below is my code
------------------------------------------------------------------------
Private Sub UserControl1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConString As String = "Data Source=<>;Initial Catalog='<>';User Id=sa;Password=<>;"
Dim MyCon As New SqlConnection
MyCon.ConnectionString = ConString
Dim DA As New SqlDataAdapter("Select [No_], [Name], [City] from [dbo].[Customer]", MyCon)
Dim DS As New DataSet
DA.Fill(DS, "[dbo].[Customer]")
Dim DataGridView1 As New DataGridView
DataGridView1.DataSource = DS.DefaultViewManager
End Sub
-------------------------------------------------------
Kindly bear with my question.
What i did is at first i dint have a datagrid, drag n dropped in the form.
When executing the code the results not getting populated to the datagrid.
please guide me where im going wrong with the codings?
Many Thanks,
Meera.