0

Dim strInsert As String
Dim cmdInsert As OdbcCommand

Dim cn As OdbcConnection
cn = New _
OdbcConnection(ConfigurationSettings.AppSettings("ConnectionString"))


strInsert = "Insert into realestate.city_master(city_Name)Values(city_name);"
cmdInsert = New OdbcCommand(strInsert, cn)
cmdInsert.Parameters.Add("city_Name", city_name.Text)


cn.Open()
cmdInsert.ExecuteNonQuery()
city_name.Text = ""
cn.Close()

3
Contributors
3
Replies
4
Views
10 Years
Discussion Span
Last Post by campkev
0

hai,
just try this out.

Dim con As OdbcConnection
Dim str As String
Dim cmd As OdbcCommand

con = New OdbcConnection
(ConfigurationSettings.AppSettings("ConnectionString"))

str = "insert into newuser_details values('" & txtusername.Text & "','" & txtpassword.Text & "')"

cmd = New OdbcCommand(str, con)
con.Open()
cmd.ExecuteNonQuery()
con.close()

try this out .it worked for me. the data is getting inserted into MySQL database.

0

that would not be a good way to do it. Opening yourself up to a SQL-injection attack

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.