For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > November 2005 > Need a help from you on VB6 programing!!!









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Need a help from you on VB6 programing!!!
Ramn

2005-11-29, 3:55 am

Hi all,

I am new to this group and VB6 as well. I have a small doubt in the
coding part. I am using VB6 with mysql 3.23.54 database. I need to
pass a string value (eg. c:\pictures\logo.gif) to the corresponding
database field called imagepath (mentioned below in the sql statement).
While I pass this value to the DB, system is updating without '\'
(special character) and we could see the data in DB as
"c:pictureslogo.gif".

Please let me know how I can able to update the value with special
characters?

I am using the code as follows:

sqlIns = "update system set user='" & txtnam..............,
imagepath='" & txtImage.Text & "' where system='system'"

cn.Execute sqlIns

It would be highly appreciated if someone could help me out to solve
this problem

Thanks and best regards
Ramn.

Phill W.

2005-11-29, 7:55 am

"Ramn" <raman.thiyyanoor@gmail.com> wrote in message
news:1133251616.078544.133230@g49g2000cwa.googlegroups.com...

> I am using VB6 with mysql 3.23.54 database.
> I need to pass a string value (eg. c:\pictures\logo.gif) to the
> corresponding
> database field called imagepath (mentioned below in the sql statement).
> While I pass this value to the DB, system is updating without ''
> (special character) and we could see the data in DB as
> "c:pictureslogo.gif".


Never used YourSQL, so this is a guess, but I would say that it's
interpreting
the "\" as a 'C'-style escape character; "They" use silly things like "\n"
for a
line break, instead of our vbCrLf.

Try doubling up the ''s as you build the SQL, as in

sqlIns = "update system " _
& "set user = '" & txtnam & "'" _
& "imagepath = '" & Replace( txtImage.Text, "\", "\\" ) & "' " _
& "where system = 'system' "

HTH,
Phill W.


Michael Cole

2005-11-29, 6:55 pm

Ramn wrote:
> Hi all,
>
> I am new to this group and VB6 as well. I have a small doubt in the
> coding part. I am using VB6 with mysql 3.23.54 database. I need to
> pass a string value (eg. c:\pictures\logo.gif) to the corresponding
> database field called imagepath (mentioned below in the sql
> statement). While I pass this value to the DB, system is updating
> without '' (special character) and we could see the data in DB as
> "c:pictureslogo.gif".


You are not actually talking about VB6 code here - you are talking about
SQL. The two are completely different languages. You would get better help
by asking in an SQL programming group. I have never used MySQL, so I cannot
recommend any groups, but if it is similar top SQL Server, you may get some
help in the microsoft.public.sqlserver.programming group.

--
Regards,

Michael Cole


joe mamma

2005-11-29, 9:55 pm

> You are not actually talking about VB6 code here -

actually he is. . .
well vb -> ado programming.

the trick is to use parameters. . . if you user parameters you dont have to
worry about special characters, quotes, etc!
the following should work:

dim cmd as new command
set cmd.activeconnection = cn
cmd.commandtext = "update system set user= ? " & _
" and imagepath= ? where system='system'"
cmd.Execute , array(txtnam, txtImage.Text)




joe mamma

2005-11-29, 9:55 pm

code should have read -

dim cmd as new command
set cmd.activeconnection = cn
cmd.commandtext = "update system set user= ?, " & _
" imagepath= ? where system='system'"
cmd.Execute , array(txtnam, txtImage.Text)


Michael Cole

2005-11-30, 3:55 am

joe mamma wrote:
>
> actually he is. . .
> well vb -> ado programming.
>
> the trick is to use parameters. . . if you user parameters you dont
> have to worry about special characters, quotes, etc!
> the following should work:


The backslash (\) is not considered a "special character" in VB strings.
All VB does is pass the string to the database. If the database has a
problem with it, then that would be the fault of the database. Easiest
solution would be to run the actual SQL statement directly against the
database and see whether it fails then.

As for your comment - quotes can be handled quite sufficiently by simply
doubling them. What other special characters are you referring to in terms
of VB String handling?

--
Regards,

Michael Cole


joe mamma

2005-11-30, 7:55 am

> All VB does is pass the string to the database. If the database has a
> problem with it, then that would be the fault of the database. Easiest
> solution would be to run the actual SQL statement directly against the
> database and see whether it fails then.


its not a fault. . . every database has characters that have syntantic
meaning to them.

the point is, if you use parameters you only need to test that the
parameterized string is correct, it should then work against ANY database.

it will also work faster in batch processing as the sql is not changed,
therefore the command gets 'prepared' against the target database.

it is also secure.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com