ronak chittora

ronak chittora

  • NA
  • 31
  • 20.7k

Error in Asp.net

Aug 5 2013 1:31 PM
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page 
{
    public OleDbConnection oledbcon;
    protected void Page_Load(object sender, EventArgs e)
    {
        String constr;
        constr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='C:\\Student.mdb'; Persist Security Info=False";
        oledbcon = new OleDbConnection(constr);
        oledbcon.Open();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String sqlstr;
        String sname;
        String percentage;
        String id;

        id = TextBox1.Text;
        sname = TextBox3.Text;
        percentage =TextBox2.Text;
        OleDbCommand cmd;
        sqlstr = "insert into stud values('id','sname','percentage')";
        //sqlstr = "select * from stud";
        cmd = new OleDbCommand(sqlstr);
        cmd.Connection = oledbcon;
        cmd.ExecuteNonQuery();
        //cmd.ExecuteReader();
        Response.Write("data saved successfully");
    }
}



in ms Acess07 
id(P.K.)as number
sname as text
percentage as text

Error::Data type mismatch in criteria expression.(at line cmd.executenonquery())
whether we have to convert string to number?? and if yes then how to do it??


Answers (2)