I am a beginner programmer and this is my first forum post, so please bear with me.
I'm using MS Visual C++ 2010 so send querys to MYSQL through an odbc connection.
So far I have had no problem inputing values into my tables but i'm struggling to create columns.
for example;
if this is how you input values into sql tables:
SQLCHAR Col1[10];
SQLINTEGER ch1;
rc = SQLPrepare(hStmt,(SQLC开发者_运维百科HAR*)"(hStmt,(SQLCHAR*)"INSERT INTO phonebook ( LastName) VALUES (?) ",SQL_NTS);
rc = SQLBindParameter(hStmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, LENGTH, 0, Col1, 0, &ch1);
...// give ch1 and Col1 values
rc = SQLExecute(hStmt);
Then would I add columns the same way???
SQLCHAR Col1[10];
SQLINTEGER ch1;
rc = SQLPrepare(hStmt,(SQLCHAR*)"ALTER TABLE phonebook ADD (? VARCHAR(45) NULL)",SQL_NTS);
rc = SQLBindParameter(hStmt, 2, SQL_PARAM_INPUT, SQL_C_CHAR, SQL_CHAR, LENGTH, 0, Col1, 0, &ch1);
...// give ch1 and Col1 values
rc = SQLExecute(hStmt);
Please help. If you could post some example code with your response so I can better understand.
Thank you so much in advance!
sarah
精彩评论