Click here to Skip to main content
16,019,349 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
XML
<body>
    <form id="form1" runat="server">
    <div>
<textbox id="txt" />
        <br />

    </div>
    </form>
</body>
Posted
Comments
Mehdi Gholam 10-Aug-13 2:57am    
You question makes little sense, edit it and supply more information.
ridoy 10-Aug-13 3:24am    
not a question at all.

So what do we understand from your above code?! Before posting such type questions you can do a search in CodeProject[^] and in Google[^].
Your code will be something look like...
C#
string sqlquery = "INSERT INTO [tableName] (ColumnName) VALUES (@textboxValue)";
    SqlCommand command = new SqlCommand(sqlquery , connection);

    string testString = testTextBox.Text;
    command.Parameters.AddWithValue("textboxValue", testString);
 
Share this answer
 
v3
Use one button in your .aspx page and runat server you text box like:


XML
<body>
    <form id="form1" runat="server">
    <div>
<textbox id="txt" runat="server" />
        <br />
 <asp:Button ID="Button1" runat="server" Text="Save" OnClick="button1_Click" />
    </div>
    </form>
</body>




private void button1_Click(object sender, EventArgs e)
       {
           SqlConnection conn = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database1.mdf;Integrated Security=True;User Instance=True;");
           try
           {
               SqlCommand cmd = new SqlCommand("INSERT INTO customers(firstName,lastName,address,city) VALUES ('wee','weeee','dfddd', 'weee')", conn);
               conn.Open();
               cmd.ExecuteNonQuery();
               MessageBox.Show("Connection Succeful");
           }
           catch (SqlException ex)
           {
               MessageBox.Show("There is an Error" + ex);
           }
           finally
           {
               conn.Close();
               MessageBox.Show("Connection Closed");
           }
       }


Accept as answer and vote if help to you.
 
Share this answer
 

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