| | |
retreive data in textbox
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 24
Reputation:
Solved Threads: 0
hi
im having problem in retreiving data in text box in C# web form.i have a combobox and a textbox.i have successfully populated combobox with data from SQL table.there are 2 tables namely employee and worker.combobox is populated with employeee data and when i select an employee it shows relevant info. in text box from the worker table.this is the point where imhaving problem.
Kindly help me.
im having problem in retreiving data in text box in C# web form.i have a combobox and a textbox.i have successfully populated combobox with data from SQL table.there are 2 tables namely employee and worker.combobox is populated with employeee data and when i select an employee it shows relevant info. in text box from the worker table.this is the point where imhaving problem.
Kindly help me.
•
•
Join Date: Oct 2007
Posts: 172
Reputation:
Solved Threads: 16
Ok use this code
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
onn.Open();
// The command settings
SqlCommand oCommand = new SqlCommand("Select * From Employee",oConn);
SqlDataAdapter oAdapter = new SqlDataAdapter(oCommand);
/* we use here data table rather than a data source because
we want just to bind a field to our textbox*/
DataTable oTable = new DataTable();
//Fill data into the data table
oAdapter.Fill(oTable);
/*We don't need the connection new as we consume data from the on memory
* cached data table so we close the connection*/
oConn.Close();
/* Assuming that we need to bind textBox1 to the FirstName Field of
* the employee table*/
textBox1.DataBindings.Add("Text", oTable, "FirstName");
using System;
using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;
onn.Open();
// The command settings
SqlCommand oCommand = new SqlCommand("Select * From Employee",oConn);
SqlDataAdapter oAdapter = new SqlDataAdapter(oCommand);
/* we use here data table rather than a data source because
we want just to bind a field to our textbox*/
DataTable oTable = new DataTable();
//Fill data into the data table
oAdapter.Fill(oTable);
/*We don't need the connection new as we consume data from the on memory
* cached data table so we close the connection*/
oConn.Close();
/* Assuming that we need to bind textBox1 to the FirstName Field of
* the employee table*/
textBox1.DataBindings.Add("Text", oTable, "FirstName");
![]() |
Other Threads in the C# Forum
- Previous Thread: how to insert image path
- Next Thread: read xml file and display to many text box
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# cast check checkbox client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ httpwebrequest image index input install java label list listbox listener mailmerge mandelbrot math mouseclick mysql operator path photoshop picturebox pixelinversion post programming radians regex remote remoting richtextbox robot save saving serialization server sleep socket sockets sql sql-server statistics stream string stringformatting sun table tcp text textbox thread time timer update usercontrol validation view visualstudio webbrowser windows winforms wpf xml





