Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB and MySQL 1

Status
Not open for further replies.

cosmoh2o

Programmer
Joined
Jul 22, 2002
Messages
92
Location
US
Please Help,
Does anybody know how to insert a variable's value into a mysql database with Visual Basic?

For Example:

Dim x as string
x = "Hello World."

Dim MyC as new OdbcCommand()
Dim Myconn as new OdbcConnection ("DSN=mysql_dsn")
Myconn.Open()
MyC.Connection = Myconn
MyC.CommandText = "INSERT INTO TABLE VALUES (x)"

I would like only the "value" of x placed in TABLE (i.e. "Hello World"). Thanks once again for any help.


 
MyC.CommandText = "INSERT INTO TABLE VALUES '" & x & "'"
 
RiverGuy,

THank you VERY much. It worked great!!!
 
NP. Just be careful to validate what that variable can contain, that it can't contain any malicious code.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top