9
Answers

how to create a csharp user interface for a sql database

Maria

Maria

16y
5.5k
1
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.
Answers (9)
0
Bechir Bejaoui

Bechir Bejaoui

NA 20.1k 5.3m 16y

OK we suppose that you have tables in your data base

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?
Accepted
0
Bechir Bejaoui

Bechir Bejaoui

NA 20.1k 5.3m 16y

datagridview[columnindex,rowindex].Value = textbox.text;
0
Maria

Maria

NA 64 0 16y
I am trying to update my datagrid using the info from text boxes rather than using the binding navigator to directly input the information.  I was hoping that I can fill in the fields with the info and click a button to update my datagrid.  Is this possible?  If so how?
0
Maria

Maria

NA 64 0 16y
By the way thanks.
0
Maria

Maria

NA 64 0 16y
Each page of what?  I'm sorry for being this slow.  I wish I could show you a picture of what I am talking about.  I have a windows form opened in design view with buttons along the left side.  I want to be able to click each button and access various info from the database.  I also would like to update each table using this gui.  Thank you for being so patient with me so far.  I really appreciate your help.
0
Bechir Bejaoui

Bechir Bejaoui

NA 20.1k 5.3m 16y


System.Data.SqlClient.SqlConnection oConn;
            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

0
Maria

Maria

NA 64 0 16y
SQL - Storage based database.  I used the Visual Studio wizard. 
0
Maria

Maria

NA 64 0 16y
SQL - Storage based database.  I used the Visual Studio wizard. 
0
Bechir Bejaoui

Bechir Bejaoui

NA 20.1k 5.3m 16y

what kind of database did you use