Hey guys,
I am reading data from an MS SQL database into a DataGrid.
What I'm trying to accomplish is to read the contents of a specific Column & Row from the DataGrid, after the information has populated from the SQL Server, and place it into a textbox or dropdown box.
What I've done so far is
I have removed some of the useless code that shows the importing of data from the server.
I have scoured the internet looking for how to read the contents of a DataGrid and have found nothing that worked. I am eager to learn and if I could be pointed in the right direction that would be awesome.
Thanks!
I am reading data from an MS SQL database into a DataGrid.
What I'm trying to accomplish is to read the contents of a specific Column & Row from the DataGrid, after the information has populated from the SQL Server, and place it into a textbox or dropdown box.
What I've done so far is
Private da As New SqlDataAdapter("SELECT * FROM Phone_Info", cs)
Private ds As New DataSet
Private cmb As New SqlCommandBuilder(da)
Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
da.Fill(ds, "Phone_Info")
dg.DataSource = ds.Tables("Phone_Info")
End Sub
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
da.UpdateCommand = cmb.GetUpdateCommand
da.Update(ds.Tables("Phone_Info"))
' The following 2 lines are where I believe the issue is at. I have tried changing these numbers around
' and the only thing that happens is a return of "0".
PhoneName = dg.Columns(0).ToString
TextBox1.Text = PhoneName
'I also tried this code with the same results.
' TextBox1.Text = (ds.Tables.IndexOf("PhoneName").ToString)
End Sub
I have removed some of the useless code that shows the importing of data from the server.
I have scoured the internet looking for how to read the contents of a DataGrid and have found nothing that worked. I am eager to learn and if I could be pointed in the right direction that would be awesome.
Thanks!