0
<asp:TextBox ID="txtfrname" runat="server" placeholder="First Name" Height="25px" Width="250px">
<asp:TextBox ID="txtlaname" runat="server" placeholder="Last Name" Height="25px" Width="250px" />
<asp:TextBox ID="txtmob" runat="server" placeholder="Mobile Number" TextMode="Number" Height="25px" Width="250px"></asp:TextBox>
<asp:Button ID="Signup" runat="server" Class="btn" OnClientClick="validate()" OnClick="Signup_Click" Text="Register" style="width:120px; height:35px;font-weight:normal;font-family:Arial; font-size:small; color:white; background-color:#ff4500; border-width:0PX; border-style:None" onmouseover="this.style.backgroundColor='#ff6933';return true;"  onmouseout="this.style.backgroundColor='#ff4500'; return true;" />

C# code:

protected void Signup_Click(Object sender, EventArgs e)
{
    string s1 = txtfrname.Text;
    string s2 = txtlaname.Text;
    string s3 = txtmob.Text;             

    long a = Convert.ToInt64(s3);

    string sql = "insert into Register values('" + s1 + "','" + s2 + "'," + a + ")";

    SqlConnection con = mydb.mycon();
    SqlCommand com = new SqlCommand(sql, con);

    con.Open();
    com.ExecuteNonQuery();
    con.Close();    

    Response.Redirect("account.aspx");
}
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
ARIT
  • 1
  • 4
  • 1
    Yes - and? **AT LEAST** tell us what the complete error is - remember: we cannot see your screen, nor read your mind - you'll have to **TELL US!** so we can possibly help you .... – marc_s Jun 26 '18 at 20:56
  • [SQL Injection alert](http://msdn.microsoft.com/en-us/library/ms161953%28v=sql.105%29.aspx) - you should **not** concatenate together your SQL statements - use **parametrized queries** instead to avoid SQL injection - check out [Little Bobby Tables](http://bobby-tables.com/) – marc_s Jun 26 '18 at 20:56
  • Error:- The network path was not found con.Open(); – ARIT Jun 26 '18 at 21:03
  • Also getting error for this- Input string was not in a correct format. string s3 = txtmob.Text; long a = Convert.ToInt64(s3); – ARIT Jun 26 '18 at 21:11

0 Answers0