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()

well, what is the value of city_name.Text when you run the query

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.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.