Getting run time error when trying to insert values into local database

22 views Asked by At
<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");
}
0

There are 0 answers