Need help in C# with a database
I need to create a program using any language and i chose c# because i am most familiar with it. This programs has to keep information of customers, have an invetory to keep stock of items, keep track of sales and other basic stuff.
What I can think of is to use c# to create the program and link it to MYSQL. Is there any better way I can do it?
Can anyone give me links to where I can learn MYSQL easily? I have done a bit of Access and SQLWorld.
Thanks
Mihai si atatPosted Jan 13, 2006, 4:27 PM
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);