0

i want to insert textbox's content into money column in sql.but i don't know how to do it.
Please help me
Thank u!

2
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by thuyson
0

well... I'm not good in that but:
1. create query more or less like that:

string query = "update tableName set money=" + textbox1.Text.Trim() + "where id=2";

2. construct connection string... if you do not know how to do that use wizard... to do that select from main menu of VS: Data -> Add new data source -> Choose a datasource tylpe (database) -> click New connection and copy the connection string constructed by the wizard...
3. connect to a database and execute query:

using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(query, connection);
                connection.Open();
                SqlDataReader sqlReader = command.ExecuteReader();

                 while (sqlReader.Read())
                 {
                     // check the result
                 }
            }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.