Click to See Complete Forum and Search --> : how to send parameter through sql create table statement?


BilginCetin
August 6th, 2004, 05:00 AM
hi again


OleDbCommand * myOleDbCommand = new OleDbCommand("CREATE TABLE SYSTEM.BILO2 ( ? INTEGER NOT NULL)",myOleDbConnection);

myOleDbConnection->Open();

myOleDbCommand->Parameters->Add("iid2", OleDbType::Char)->Value=this->textBox7->Text;
i d like to send parameter from textbox through the question mark in sql statement but i guess it sends parameter like: ' TEXT ' instead of TEXT. this makes error for create statement, doesnt it? what can i do?thanks.

Vaderman
August 6th, 2004, 06:26 AM
I suggest you create a string in your resources:


IDS_CREATE_TABLE = "CREATE TABLE %s (%s INTEGER NOT NULL)"

where the first %s is your table name and the 2nd is your column name.

You could also make it a little more versatile by doing the following, if you wish:


IDS_CREATE_COLUMN = "(%s %s)"
IDS_CREATE_TABLE = "CREATE TABLE %s %s";


and then you can do this :


strColumn.Format(IDS_CREATE_COLUMN, "My Column", "INTEGER NOT NULL");
strTable.Format(IDS_CREATE_TABLE, "Table Name", strColumn");


hope that helps.