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!

Recommended Answers

All 2 Replies

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
                 }
            }

thank Szpilona,i miss excutereader()!
thank u so much!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.