Why does it insert NULL values into MySQL DB???

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2006
Posts: 11
Reputation: vaisakh is an unknown quantity at this point 
Solved Threads: 0
vaisakh vaisakh is offline Offline
Newbie Poster

Why does it insert NULL values into MySQL DB???

 
0
  #1
Dec 22nd, 2006
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()
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Why does it insert NULL values into MySQL DB???

 
0
  #2
Dec 22nd, 2006
well, what is the value of city_name.Text when you run the query
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 29
Reputation: hkarthik is an unknown quantity at this point 
Solved Threads: 0
hkarthik hkarthik is offline Offline
Light Poster

Re: Why does it insert NULL values into MySQL DB???

 
0
  #3
Jan 12th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 483
Reputation: campkev is an unknown quantity at this point 
Solved Threads: 19
campkev campkev is offline Offline
Posting Pro in Training

Re: Why does it insert NULL values into MySQL DB???

 
0
  #4
Jan 12th, 2007
that would not be a good way to do it. Opening yourself up to a SQL-injection attack
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC