Main program:
Currently I have this to call the connection:
private void buttonDBConnect_Click(object sender, EventArgs e)
{
DBServer = textBoxProfileServer.Text;
DBDatabase = textBoxProfileDatabase.Text;
DBLogin_ID = textBoxProfileLogin_ID.Text;
DBPassword = textBoxProfilePassword.Text;
//
ClassDB.Connection(DBServer, DBDatabase, DBLogin_ID, DBPassword);
}
This fills my dataGrid:
private void buttonLoadGrid_Click(object sender, EventArgs e)
DBCommand =
" SELECT"
+ " [Name]"
+ " ,[Address_1]"
+ " FROM"
+ " [Company]"
;
ClassDB.Select(DBCommand);
SqlDataAdapter DBDataAdapter = new SqlDataAdapter(ClassDB.DBSelect, ClassDB.DBConnect);
DataSet DBDataSet = new DataSet();
DBDataAdapter.Fill(DBDataSet);
dataGridViewGrid.DataSource = DBDataSet.Tables[0];
dataGridViewGrid.Refresh();
Class:
This does the connection:
public static void Connection(string DBServer, string DBDatabase, string DBLogin_ID, string DBPassword)
//MessageBox.Show("DBClass: Connection");
DBConnect =
@"Server=" + DBServer + ";"
+ "Database=" + DBDatabase + ";"
+ "User ID=" + DBLogin_ID + ";"
+ "Password=" + DBPassword + ";";
//MessageBox.Show("DBConnect: With:" + DBConnect);
try
//MessageBox.Show("TRY...");
SqlConnection DBConnection = new SqlConnection();
DBConnection.ConnectionString = DBConnect;
DBConnection.Open();
DBConnection.GetSchema();
catch
//MessageBox.Show("CATCH...");
finally
//MessageBox.Show("FINALLY...");
//////////////////////////////////////////////////////////////////////////////////////////////////
What I would like to do is to call my DBClass.LoadGrid. By calling it like this: DBClass.LoadGrid(DBCommand);
This is what I have in my DBClass.LoadGrid now. What should I have in it?
public static void LoadGrid(string DBCommand)
//MessageBox.Show("DBLoadGrid: With:" + DBCommand);
DBLoadGrid = DBCommand;