hii users,
i am currently working on a webpage (Registration page)..and in that i have some fields in a table ,they are - (Name,Comp_Name,User_Name,Email_Id,Password,User_Image,Category,Status) and 1 id textbox. i want the id to fetch the data of the row that has been entered in the id field on its textchange event. for example.if i type 101 in id and enter it,then the records of 101 should get fetched from the database.plz help me out ASAP
Wim SturkenboomPosted Sep 29, 2014, 12:50 AM
Assuming you know how to setup a connection to the database, the following show the basics to retrieve all records with ID 101
// ID of interest
int theID = 101;
// the query; not the use of the parameter
SqlCommand cmd = new SqlCommand("select * from mytable where ID = @pID", myConnection);
// set the command type
cmd.CommandType = System.Data.CommandType.Text;
// add the parameter
cmd.Parameters.AddWithValue("@pID", theID);
// define a table to store results
DataTable tbl = new DataTable();
// execute query and populate table
tbl.Load(cmd.ExecuteReader());
You need to 'include' the namespaces System.Data and System.Data.SqlClient.
Saineshwar BageriPosted Sep 29, 2014, 1:15 AM
Animesh MishraPosted Sep 29, 2014, 1:06 AM
Riddhi ValechaPosted Sep 29, 2014, 12:41 AM
select * from tablename where columnnmae = '"&textbox1.text.trim()&"';
----------
If possible, can you please zip the project and send??
Saineshwar BageriPosted Sep 29, 2014, 12:40 AM