|
-
Jan 22nd, 2003, 02:00 PM
#1
Thread Starter
New Member
SQL VB problem
I have a query that is returning a value
Cable Fem 6'
I am now trying to insert into a new table but keep getting an error statement can not be prepared
Insert into I2DE100M (I2IZPN, I2PMFAM) VALUES('DSUB FEM LAB 6'', 'DEBO')
the extra single quote after the 6 is the issue but is needed
I can go to sql anlizer and put double quotes and it works but how do I get the vb statement to pass the dbl qutes in the query string??
-
Jan 22nd, 2003, 02:15 PM
#2
You would use the same code as you used in Query Analyzer (with two single quotes where there is one in the data) in your VB program:
e.g.:
strSQL = "Insert into I2DE100M (I2IZPN, I2PMFAM) VALUES('DSUB FEM LAB 6'', 'DEBO') "
if you are using variables for your data (for example from a textbox) and don't know whether or not the incoming data has a single quote, you can use the replace function like so:
strValue1 = Replace(Text1.Text, "'", "''")
strValue2 = Replace(Text2.Text, "'", "''")
strSQL = "Insert into I2DE100M (I2IZPN, I2PMFAM) VALUES('" & strValue1 & '", '" & strValue2 & "') "
"It's cold gin time again ..."
Check out my website here.
-
Jan 22nd, 2003, 02:48 PM
#3
Thread Starter
New Member
thank you
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
|