•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C# section within the Software Development category of DaniWeb, a massive community of 423,538 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,292 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C# advertiser: Programming Forums
Views: 1607 | Replies: 2
![]() |
•
•
Join Date: Nov 2007
Posts: 22
Reputation:
Rep Power: 0
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: 92
Reputation:
Rep Power: 1
Solved Threads: 8
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");
![]() |
•
•
•
•
•
•
•
•
DaniWeb C# Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
access advice breach broadband business classification code combo crime daniweb data data protection data transfer database drive dropdownlist encryption europe forensic forensics fun government hard hardware help hitachi hp industrial espionage information internet it linux module net news payment services privacy protection reuse security storage terabyte tutorials and more web wikipedia you tried to assign the null value to a variable that is not a variant data type
- Previous Thread: how to insert image path
- Next Thread: read xml file and display to many text box


Linear Mode