SqlClient.SqlConnection.CreateCommand and an open connection?

I have an application (VB.net) which has two routines that process nonquery SQL command requests.

One routine queues commands up as they come in and the other pulls them out of the queue on a timed basis FIFO style. I essentially just pre-create a SQL command, enqueue it, and then execute it when it gets pulled from the queue.

My question is this: does SqlClient.SqlConnection.CreateCommand require a specific connection string to create a command or can that be left for when the command is actually processed?

Due to the asymmetric nature of the processing of these commands I would prefer only to have to open connections to the database on the executing end. The examples I have seen all show a command being created with a specific connection string and usually an opened connection.

I can provide code snippets but I really just need to find out what is mandatory in order to create a SQL command.
LVL 1
kkammAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
and yes, you can provide the connection object at a later time.
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
what about just using

dim cmd as SqlClient.SqlCommand = new SqlClient.SqlCommand
0
 
kkammAuthor Commented:
That is what I thought but I just wanted to make sure before changing a bunch of code. Thanks
0
All Courses

From novice to tech pro — start learning today.