Is there any way that I can retrieve any data from the database in the SQL server without using the DataGrid viewer or alike?
I want to retrieve a data that would go straightly to the textbox but not in the DataGrid.
Although I'm already used of retrieving files coming from the datagrid to the the textbox, can i just retrieve it directly from the database itself?
any ideas?
Vijaya KadiyalaPosted Jun 24, 2008, 3:59 PM
Hi,
Thanks for your comments
regard -- Vj
Bechir BejaouiPosted Jun 3, 2008, 7:15 PM
Vijaya KadiyalaPosted Apr 7, 2008, 3:06 PM
You could just do the query in the Page_Load as suggested, and populate the TextBox that way.
For example, here is an example using the Northwind sample database:
Mervha NifflemhellPosted Apr 3, 2008, 7:04 PM
inside the sdr, does
'cus' means the name of the table
'int' means the sql data type
'CustomerName' means the field name
am i getting it right?
Niradhip ChakrabortyPosted Apr 3, 2008, 8:14 AM
It is very simple.Just read the data from table using data reader and and assign the data in textbox. I have given the code below.
if (sdrData.HasRows)
{
if (sdrData.Read())
{
txtCustomerID.Text = sdrData["cus_vch_Id"].ToString();
txtCustomerName.Text = sdrData["cus_vch_CustomerName"].ToString();
txtAddress.Text = sdrData["cus_vch_Address"].ToString();
txtCity.Text = sdrData["cus_vch_City"].ToString();
txtState.Text = sdrData["cus_vch_State"].ToString();
txtZip.Text = sdrData["cus_int_Zip"].ToString();
txtTelephone.Text = sdrData["cus_vch_Telephone"].ToString();
txtFax.Text = sdrData["cus_vch_Fax"].ToString();
txtEmail.Text = sdrData["cus_vch_Email"].ToString();
txtWebsite.Text = sdrData["cus_vch_WebsiteAddress"].ToString();
txtUserLicences.Text = sdrData["cus_int_MaximumNoLicenses"].ToString();
}
}