how to create a csharp user interface for a sql database
I've created an sql inventory database with four tables using Visual Studio. I need to create a user friendly GUI that can access this database. I want to do simple searches, update the tables and display what is available. I am so lost and I need a lot of help. I do not know where to start and I barely know how to use Visual Studio. I am very new to c# so please go slow with me. Thank you in advanced.
Bechir BejaouiPosted Dec 8, 2008, 6:22 AM
each table should be represented in a separate form
for suppose this table is sql server
Person(CUSTOMER_ID,NAME,SALARY)
you can repserent it in a window form using a datagridview, you just drag and drop a datagridview in your Form and doubleclick the Form then add this code to the form load event handler
try
{
oConn.Open
sqlcommand oComm = new sqlCommand("SELECT CUSTOMER_ID,NAME,SALARY , oConn);
sqlDataAdapter oAdapter = new sqlDataAdapter(oComm);
dataTable dt = new datatable();
oAdapter.Fill(dt);
datagridview1.datasource = dt;
datagridview1.datamember = dt.tablename;
}
finally
{
oConn.Close();
}
you do same thing to the other tables, if you ever encounter the problem then send me your mail and I send you a video tutorial that I will do for you. OK?
Bechir BejaouiPosted Dec 9, 2008, 8:17 PM
MariaPosted Dec 8, 2008, 5:09 PM
MariaPosted Dec 8, 2008, 4:59 PM
MariaPosted Dec 7, 2008, 5:51 PM
Bechir BejaouiPosted Dec 7, 2008, 5:10 PM
oConn = new System.Data.SqlClient.SqlConnection();
oConn.ConnectionString = "Data Source=YourServer;Initial Catalog=YourDataBaseName;Integrated Security=true";
oConn.Open();
System.Data.SqlClient.SqlCommand oComm;
oComm = new System.Data.SqlClient.SqlCommand();
System.Data.DataTable dt = new System.Data.DataTable();
oComm.CommandText = "your sql query for table 1";
System.Data.SqlClient.SqlDataAdapter oAdapter;
oAdapter = new System.Data.SqlClient.SqlDataAdapter(oComm);
oAdapter.Fill(dt);
oConn.Close();
Add a datagridview to your project
datagridview1.datasource = dt;
datagridview1.datamember = dt.tablename;
that's it, for each page do the same thing
MariaPosted Dec 7, 2008, 2:42 PM
MariaPosted Dec 7, 2008, 2:42 PM
Bechir BejaouiPosted Dec 7, 2008, 2:33 PM