I'm using ADO from VBA to send a CreateTable statment to a SQL server. My connection string looks like this:
"Provider=SQLOLEDB;Server=ServerName;Intitial Catalog=DatabaseName;Integrated Security=SSPI"
I create a command object that uses the above connection string. I set the command object's commandText property to my CreateTable statement. When I execute my make table statement, the table is created in the Master database and not the one specified by my connection string (DatabaseName). I've gotten around this by executing a "USE DatabaseName" statment through my command object before I execute the CreateTable.
My question is. Is there a better way? Am I missing something, or is this how I have to do it?
Thanks
"Provider=SQLOLEDB;Server=ServerName;Intitial Catalog=DatabaseName;Integrated Security=SSPI"
I create a command object that uses the above connection string. I set the command object's commandText property to my CreateTable statement. When I execute my make table statement, the table is created in the Master database and not the one specified by my connection string (DatabaseName). I've gotten around this by executing a "USE DatabaseName" statment through my command object before I execute the CreateTable.
My question is. Is there a better way? Am I missing something, or is this how I have to do it?
Thanks