by ssi
15. December 2015 15:33
private bool GotConnected2SQL(string sConnectionString)
{
bool bRet = false;
SqlConnection mySQLConnection = new SqlConnection(sConnectionString);
string SQLStatement = "SELECT control FROM [tbvl_ssi_control]";
string sSql = string.Format(SQLStatement);
SqlCommand mySQLCommand = mySQLConnection.CreateCommand();
try
{
mySQLCommand.CommandText = sSql;
SqlDataAdapter mySQLDataAdapter = new SqlDataAdapter();
mySQLDataAdapter.SelectCommand = mySQLCommand;
DataSet myDataSet = new DataSet();
mySQLConnection.Open();
Console.WriteLine("Retrieving rows from the Query");
mySQLDataAdapter.Fill(myDataSet, "RECS");
mySQLConnection.Close();
DataTable myDataTable = myDataSet.Tables["RECS"];
bRet = true;
}
catch (Exception ex)
{
MessageBox.Show(string.Format("", "SQL Connection Error: {0}", ex.Message), "SQL Connection Status", MessageBoxButtons.OK, MessageBoxIcon.Error);
bRet = false;
}
return bRet;
}