|
-
Jul 4th, 2006, 11:27 PM
#1
Thread Starter
New Member
[RESOLVED] [2005] Variable inside an SQL Query? Help please.
This is how I thought it was done but everytime I try this I get an error.
VB Code:
For Each FoundMatch As System.Text.RegularExpressions.Match In Mymatches
Dim table8 As String = FoundMatch.Value
MsgBox(table8)
conn.Execute("CREATE TABLE " & table8 & "(file_id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, file_name VARCHAR(64) NOT NULL, file_size MEDIUMINT UNSIGNED NOT NULL, file MEDIUMBLOB NOT NULL)")
Next
The error is...
Code:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2147217900
Message="[MySQL][ODBC 3.51 Driver][mysqld-5.0.18-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '30(file_id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, file_name VARC' at line 1"
Source="Microsoft OLE DB Provider for ODBC Drivers"
-
Jul 4th, 2006, 11:29 PM
#2
Thread Starter
New Member
Re: [2005] Variable inside an SQL Query? Help please.
One more thing...everything works fine when I'm not trying to place a variable inside the code.
-
Jul 4th, 2006, 11:47 PM
#3
Re: [2005] Variable inside an SQL Query? Help please.
Use angle quotes (`) around field, table, and database names. Single quotes (') around string literals (be careful to escape any single quotes that might go into those strings with backslashes \'). No quotes around numbers.
-
Jul 4th, 2006, 11:55 PM
#4
Thread Starter
New Member
Re: [2005] Variable inside an SQL Query? Help please.
VB Code:
conn.Execute("CREATE TABLE table8(file_id SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, file_name VARCHAR(64) NOT NULL, file_size MEDIUMINT UNSIGNED NOT NULL, file MEDIUMBLOB NOT NULL)")
I'm sorry...that's a little too advanced and unclear for me. Could you please point me in the right direction with my current code above ^ table8 is the variable I wanna use.
-
Jul 5th, 2006, 12:08 AM
#5
Re: [2005] Variable inside an SQL Query? Help please.
VB Code:
conn.Execute( _
"CREATE TABLE `" + table8 + "` (" + _
" `file_id` SMALLINT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, " + _
" `file_name` VARCHAR(64) NOT NULL, " + _
" `file_size` MEDIUMINT UNSIGNED NOT NULL, " + _
" `file` MEDIUMBLOB NOT NULL)" _
)
I tested that exact query on a MySQL client with no problems.
-
Jul 5th, 2006, 12:25 AM
#6
Thread Starter
New Member
Re: [2005] Variable inside an SQL Query? Help please.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|