Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
SQL
I have the table in the below format.



FirstName Last Name
Jill Smith
Eve Jackson

Also i have Form for updating the firstname & lastname. This is the form code.

XML
<!DOCTYPE html>
<html>
<body>

<form border="1">
  <tr>
     <td><label >FirtsName</label></td>
     <td><input type="text" id="firstname" class="medium"></td>
    </tr>
  <tr>
   <td><label >LastName</label></td>
   <td><input type="text" id="lastname" class="medium"></td>
   </tr>

</form>

</body>
</html>



SQL
How to send the table data to a form using jquery or javascript. Any help will be much appreciated!

Thanks & regards Karthick
Posted

1 solution

Hi Karthick,
You need to use SqlDataReader Object to read the data from database. And also you can assign the value of your table to a control using reader object.
See the link:
Retrieving Data Using the DataReader[^].
Try this:
C#
SqlConnection con = new SqlConnection("YourConnectionStringHere");
con.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM Table1", con);
SqlDataReader sdr = cmd.ExecuteReader();
while(sdr.Read())
{
    TextBox1.Text = Convert.ToString(sdr["FirstName"]);
    TextBox2.Text = Convert.ToString(sdr["LastName"]);
}
//Releasing the objects
sdr.Dispose();
cmd.Dispose();
con.Close();


--Amit
 
Share this answer
 
v2
Comments
Karthick88it 15-Mar-13 0:46am    
Hi Amit

I am not using any database here. Just to show the row from the table to a form.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900