ronak chittora

ronak chittora

  • NA
  • 31
  • 20k

ASP.net

Aug 6 2013 3:43 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;
int id;

id = convert.toint32(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

nw i have to upload image or file whatever so what should be added in this code and into database for storing it also (what type of data type )should i use to do it and what will be added in programe






Answers (3)