944,191 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 5440
  • ASP.NET RSS
Dec 22nd, 2006
0

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

Expand Post »
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()
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vaisakh is offline Offline
11 posts
since Mar 2006
Dec 22nd, 2006
0

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

well, what is the value of city_name.Text when you run the query
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005
Jan 12th, 2007
0

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

hai,
just try this out.


Quote ...
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.
Reputation Points: 10
Solved Threads: 0
Light Poster
hkarthik is offline Offline
29 posts
since Jan 2007
Jan 12th, 2007
0

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

that would not be a good way to do it. Opening yourself up to a SQL-injection attack
Reputation Points: 14
Solved Threads: 19
Posting Pro in Training
campkev is offline Offline
484 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Asp.net
Next Thread in ASP.NET Forum Timeline: Microsoft.BusinessFramework, or one of its dependencies, was not found





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC