|
-
Nov 25th, 2005, 10:17 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] ODBC SQL Parameters
Hello,
im need to write data to a 3rd party database in which i cannot rename columns etc...
many of the column names contain a "-" in them eg: prod-name
im trying to contruct a parameterised query but im having problems
VB Code:
"INSERT INTO Products (""prod-name"") VALUES (?)"
im using the double quotes so the database will accept the "-"
VB Code:
Dim l_sqlCmd = l_sqlConnection.CreateCommand()
l_sqlCmd.Parameters.Add("@prod-name", "My Product")
l_sqlCmd.Prepare()
l_sqlCmd.ExecuteNonQuery()
will the parameters accept the parameter name as in the SQL statement there are the double quotes
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Nov 25th, 2005, 10:20 AM
#2
Re: ODBC SQL Parameters
Can you use "[" and "]" instead of the double quotes, or are you stuck with the query as-is?
-
Nov 25th, 2005, 10:22 AM
#3
Thread Starter
Fanatic Member
Re: ODBC SQL Parameters
im stuck with it as it. The database is a progress one so its very very very picky about what you can do.
im just wondering will it ignore the inner quotation marks
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Nov 25th, 2005, 10:29 AM
#4
Re: ODBC SQL Parameters
I don't think so. I think it's still going to try and calculate the column names. You aren't able to do something like this in your code to INSERT?
"INSERT INTO Products ([prod-name], [prod-desc]) VALUES (@prodname, @proddesc)"
l_sqlCmd.Parameters.Add("@prodname", "My Product")
l_sqlCmd.Parameters.Add("@proddesc", "My Product Description")
-
Nov 25th, 2005, 10:40 AM
#5
Thread Starter
Fanatic Member
Re: ODBC SQL Parameters
no it doesnt recognise the [] it gives a syntax error.
it worked for the double quotes """" except for when trying to insert a date
hmmmm
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Nov 25th, 2005, 10:46 AM
#6
Re: ODBC SQL Parameters
Hmmmm; what kind of database is the 3rd party using?
(I ran the statement in my analyzer and it worked for me)
-
Nov 25th, 2005, 10:48 AM
#7
Thread Starter
Fanatic Member
Re: ODBC SQL Parameters
its a Progress Database....
Barry
Visual Studio .NET 2008/Visual Studio .NET 2005/Visual Studio .NET 2003
.NET Framework 3.0 2.0 1.1/ASP.Net 3.0 2.0 1.1/Compact Framework 1.0
SQL Server 2005/2000/SQL Server CE 2.0
If you like, rate this post
Compact Framework for Beginners
-
Nov 25th, 2005, 10:59 AM
#8
Re: ODBC SQL Parameters
Try using single quotes around the string you will send
" ' INSERT INTO Products ("prod-name") VALUES (?)' "
or
"INSERT INTO Products ('prod-name' ) VALUES (?)"
a lot of SQL interpreters use single quotes for string that shoudn't be proccessed before interpreting.
fiddle around a bit maybe you wil get lucky.
Groeten Berend
 why can't programmers keep and 31 Oct and 25 dec apart. Why Rating is Useful
for every question you ask provide an answer on another thread.
-
Nov 25th, 2005, 11:03 AM
#9
Re: ODBC SQL Parameters
I did some looking around about progress. From the looks of it, it handles column names with '-' as if it was just another character. In the examples, you don't need to do anything with it:
Look under "Data Manipulation Language" --> "Inserting Rows"
http://www.progress.com/progress/pro...oa/s89/s89.pdf
When you give the date parameter to the statement, how are you doing it?
I've been trying to figure out the statement, but it looks a little too pseudo to really understand why only a date wouldn't work.
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
|