0
Here are some useful links:
http://samples.gotdotnet.com/quickstart/aspplus/doc/webdataaccess.aspx.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/adon_wtaccessdb.asp.
/*for accesing a MS ACCESS Database*/
string strParameters = @Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\db\elearning.mdb;User Id=admin;Password=;
OleDbConnection oleConn =
new OleDbConnection(strParameters);
OleDbCommand comGet =
new OleDbCommand("SELECT * FROM Questions WHERE CourseID='" + CourseID + "'", oleConn);
oleConn.Open();
try{
OleDbDataReader dr = comGet.ExecuteReader(); //for reading the database
while(dr.Read())
// returneaza false daca nu mai sunt inregistrari de citit {
Response.Write(dr[0].ToString());
int varsta = (
int)dr["Varsta"];
}
}
finally{
oleConn.Close();
}
/*for inserting data into a database*/
OleDbCommand com =
new OleDbCommand("INSERT INTO Marks (SignInID, LessonID, PostedHomework) Values('" + SignInID + "','" + ID + "','1')", oleDbConn);
try{
oleDbConn.Open();
com.ExecuteNonQuery();
}
catch(OleDbException)
{
return "Could not mark the homework!!!";
}
finally{
oleDbConn.Close();
}
/* for accessing a Sql Server database */
string strParameters = @Data Source=Alex;Initial Catalog=elearning;User Id=sa;Password=parolasa;
SqlConnection sqlConn =
new SqlConnection(strParameters);
