C# Programming
01-27-2010, 01:30 PM
I'm stepping into a whole new programming world which I'm not used to at the moment and seemingly stuck at the first hurdle.
I have a class called SQLDBConnect.cs This class is given parameters to connect to a database e.g username password, server etc. These are pulled into an SQLConnection and opened. That appears to work fine.
Within another class I am trying to write an INSERT into that database and I'm stuck at the command
SqlCommand myCommand = new SqlCommand();
myCommand.Connection =;
How do I tell the command to use the connection which is opened in the SQLDBConnect class?
As I mentioned I am new to all this and may be taking the wrong approach, I'd appreciate any opinions.
Many Thanks for all help
I have a class called SQLDBConnect.cs This class is given parameters to connect to a database e.g username password, server etc. These are pulled into an SQLConnection and opened. That appears to work fine.
Within another class I am trying to write an INSERT into that database and I'm stuck at the command
SqlCommand myCommand = new SqlCommand();
myCommand.Connection =;
How do I tell the command to use the connection which is opened in the SQLDBConnect class?
As I mentioned I am new to all this and may be taking the wrong approach, I'd appreciate any opinions.
Many Thanks for all help