-
March 13th, 2012, 03:18 PM
#1
Populate value in textboxes
hi guys,
I have budget table in my sql database and there are some field like budgetYear,Long-term,short-term etc.. and I have textboxes and i want to get value from textbox. so how can i get? can you guys please help me.
Thanks a lot
-
March 13th, 2012, 04:33 PM
#2
Re: Populate value in textboxes
So you have a sql db and a form and would like to bind some controls to some fields.
Have you at least decided how your software will deal with db?
are you going for Entity Framework?
are you going for Linq to Sql?
are you going for a custom Dal with Objects to map your tables?
are you going for strongly typed DataSet?
are you going for simple DataTables?
?
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
-
March 15th, 2012, 07:15 AM
#3
Re: Populate value in textboxes
That was hardly a useful reply, as the OP will obviously not be able to answer those questions.
I would suggest looking at the SqlDataReader class.
This sample should get you started (modified from MSDN)
Code:
private static void ReadOrderData(string connectionString)
{
string queryString = "SELECT whatever FROM some_table";
using (SqlConnection connection = new SqlConnection(connectionString))
{
using SqlCommand command = new SqlCommand(queryString, connection))
{
command.Connection.Open();
using(SqlDataReader reader = command.ExecuteReader())
{
// Call Read before accessing data.
while (reader.Read())
{
textBox1.Text = reader["column_name"].ToString();
}
}
}
}
}
EDIT: I might have misunderstood, and you want to save the textbox values to your database? If that's the case, let me know and I'll help out as best I can
It's not a bug, it's a feature!
-
March 27th, 2012, 03:43 PM
#4
Re: Populate value in textboxes
hi guys,
I have textboxes and I want to display a last row from database table.
I also have add button ,it will insert data in databse table.
So when user update table every time I want to display last row only.
what should I do?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|