George Trevour Dsouza
George Trevour Dsouza

Reputation: 171

Populating Text Boxes in VB.NET

I have a small requirement and that is as follows:

I am calling a stored procedure and based on the results from the stored procedure, i want to display the data into textboxes. I am using DataSet and DataAdapter for the same. Can anyone help me. My code is as follows:

Dim sqlStripCmd As New SqlCommand("prcAdt_mwo_strip_det_sel", connection.conn)  
  sqlStripCmd.CommandType = CommandType.StoredProcedure  
  sqlStripCmd.Parameters.Add("@strip_no", SqlDbType.Char, 3).Value = txtMwoStpNo.Text  
  sqlStripCmd.ExecuteNonQuery()  
  Dim getDetailsDS As New DataSet  
  Dim getDetailsDA As New SqlDataAdapter  
  getDetailsDA = New SqlDataAdapter  
  getDetailsDA.SelectCommand = sqlStripCmd  
  getDetailsDA.Fill(getDetailsDS, "getDetails")  

I am getting the data and am able to display it into a datagrid, but how do i put it into textboxes.

Please help on the same.

Upvotes: 0

Views: 1342

Answers (2)

TechTravelThink
TechTravelThink

Reputation: 3094

yourTextBox.Text = getDetailsDS.Tables(0).Rows(0).Item(0) // corrected Fields to Item

Upvotes: 0

Matt
Matt

Reputation: 14551

It kind of depends on how much data you have in the dataset since they can hold multiple tables. One way is to find the table within the dataset that has fields you want to display and programmatically fill the textbox.

Example:

txtBox.Text = getDetailsDS.Tables("TableName").Row(0).Item("ColumnName").ToString()

Upvotes: 2

Related Questions