I am developing a series of processes in C# which reuse the same SQL code. Below is an example of a Class I created for the SQL Connection to my test database. Question: how to do I call the Class in my process? I have tried a couple of things however, I get the below errors
Errors:
SQLHelperCode.FirstConnect is a 'type' which is not valid in the given context.
Only Assignment, call, increment, decrement and new object expressions can be used as a statement
Class FirstConnect
public class FirstConnect
{
public FirstConnect()
{
SqlConnection conn;
string path = @"C:\Program Files (x86)\Microsoft SQL Server\MSSQL.1\MSSQL\Data";
const string dbName = "datadetail";
{
conn = new SqlConnection("user id=TestUser;" +
"server=TestData\\SQLEXPRESS;" +
"Trusted_Connection=yes;" +
"connection timeout=30");
try
{
conn.Open();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
Want to call the FirstConnect in this code:
protected override void OnBarUpdate()
{
accountName = Account.Name.ToString();
if (accountName == 'Test1234')
{
//Call FirstConnect here.
}
}