Last post Apr 20, 2012 01:48 PM by adamturner34
Apr 20, 2012 01:18 PM|siraero|LINK
I have a code, where i get a mail from a page with request.form then i add this to a string thenewsmail, and then i call a db connection where i get the data from the db where tableemail = thenewsmail.
Then i add the thenewsmail to a label.text and then i show a modal popup.
all work, but if thenewsmail = a mail that i know is in the db i get Response.Write("no data in db") and i know the mail is in the db and its lowercase in the mail, why cant i get the data from the db !?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim thenewsmail As String
thenewsmail = Request.Form("MasterID$newsletter")
AddedEmail.Text = thenewsmail
' Exactly the code translated in VB using reader
Using connection As OleDbConnection = New OleDbConnection(ConfigurationManager.ConnectionStrings("MyConnStr").ConnectionString)
Using command As OleDbCommand = New OleDbCommand("select * from news_users where newsuser_mail ='thenewsmail'", connection)
Using reader As OleDbDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
If reader.HasRows Then
Do While reader.Read()
Response.Write(reader("newsuser_name") & " " & reader("newsuser_name"))
Response.Write("No data in db")
Apr 20, 2012 01:48 PM|adamturner34|LINK
It may be the comparison operator. If you use = then it must be an exact match. Try switching it to LIKE '%%'