Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
insert in VB
Name: sunny Date: October 8, 2004 at 09:10:56 Pacific OS: xp CPU/Ram: 256
Comment:
hi , i got porblem when iam trying to insert a string having an apostrophy (') into SQL Server 2000 from VB .. i.e the VB statement is : cn.open "insert into table1 values('"str"')"
here my str=Raja's iam getting error with this syntax.. if str=Rajas it dosent give error.
some one pls tell me how to insert strings like the previous one..
Name: SN Date: October 8, 2004 at 10:28:28 Pacific
Reply:
before using any strings in a query with sql server, replace any instances of ' with ''.
str = replace(str, "'", "''")
Good luck, -SN
0
Response Number 2
Name: sunny Date: October 9, 2004 at 04:36:02 Pacific
Reply:
thank u for your suggestion SN but it dosent work. if i make it double qoutes it is entering double quotes not ' . pls any one tell me how to insert (') into the data base ( sql server ). thank u .
0
Response Number 3
Name: SN Date: October 9, 2004 at 08:57:02 Pacific
Reply:
Sunny- Sorry my suggestion didn't work. I'm quite certain that is how you do it though...Try running the query manually in Server Enterprise Manager or Query Analyzer:
INSERT INTO tbl (field1) VALUES ('don''t eat yellow snow')
and see if it puts in the single apostraphe. If it doesn't, perhaps there is some setting in SQL server that needs to be changed. If it works, then something is going on in your code (maybe accidentally performing the replace twice on the same string?)
Summary: Hi, I am involved in a project in visual basic language. I developed a standalone form with an autocad insert, each time I want to perform functions such as zooming, layering, rotation of the inserted...
Summary: Its a weird beast is the VB Error Handler and it doesnt always work the way you expect. Unfortunatley, as written the ExceptionHandler will never get called. Putting On Error Resume Next at the begin...
Summary: i am doing simple programm in vb,i have designed a simple form in vb with some text boxes and two buttons to submit and cancel.After i insert the value and when click submit, i want to make these valu...