Error with sql code

Hi im triying to get somethings from mysql and generated and email from then so this is the problem now

Dim rs as RecordSet
rs = ibssts.SQLSelect( “SELECT NombreCorto, Correo FROM usuarios WHERE NoTarjeta =”+NoTarjetaGlobal)
Dim NombreCorto As String
Dim Correo As String
If rs <> Nil and rs.EOF = False then

NombreCorto = rs.Field (“NombreCorto”).getString
Correo = rs.Field(“Correo”).getString

End if

dim SendMailSocket as SMTPSecureSocket
SendMailSocket = new SMTPSecureSocket

SendMailSocket.Address = “” // your SMTP email server
SendMailSocket.Port = 465 // Check your server for the property port # to use

SendMailSocket.ConnectionType = SMTPSecureSocket.SSLv23
SendMailSocket.Secure = True

SendMailSocket.username =""
SendMailSocket.password = “”

// Create the actual email message
Dim mail As New EmailMessage
mail.FromAddress = “”
mail.Subject = " Nuevo Inicio de Seccion en su Tarjeta Numero: "+TXT_Tarjeta.Text
mail.BodyPlainText = “Hola “+NombreCorto +” Hemos detectado un inicio de seccion en la plataforma de INTERBYSS con su tarjeta numero:”+TXT_Tarjeta.Text
mail.Headers.AppendHeader(“X-Mailer”, “IBSS Tehnichal Services”) // Sample header

// Add the message to the SMTPSocket and send it

the sql do the query but dont receive anything with this and i cant fill the Correo Variable or NombreCorto for send the email because that do nothing

Dim rs as RecordSet
Dim NombreCorto As String
Dim Correo As String

rs = ibssts.SQLSelect( "SELECT NombreCorto, Correo FROM usuarios WHERE NoTarjeta ="+NoTarjetaGlobal)
if ibssts.error=false then 
If  rs.EOF = False then // no need to check for NIL, as this will occur only if there is an ERROR

NombreCorto = rs.Field ("NombreCorto").stringvalue
Correo = rs.Field("Correo").stringvalue

End if
msgbox "YOU HAD AN ERROR IN YOUR QUERY... "+db.errormessage
end if

this is off the top of my head, but you NEED to check for errors… NOT RS=nil,

You also should check for the record set being Nil. That indicates that the query is invalid.

which is exactly WHY you should do proper error checking… you catch it … before you need to worry about a NIL recordset

Hi Dave i got a error in this line If rs.EOF = false then

so rs is certainly NIL because of a bad sql query syntax…

and what was the ERROR MESSAGE???

The error is in the next image

Before you talk to something you need to make sure that it’s there. Your rs variable is nil. Do a nil check.

dim rs as recordset = ibsstr.sqlselct("some sql here") if rs = nil msgbox "nice error message here" return end if

And yes, there is always the need to check for nil.

PS: define you variable when you use them. Don’t do 2 lines for dim-ing and new-ing.

[quote=352526:@Alvin Nunez]The error is in the next image

no image showing

Why is everyone so fixated on RS=NIL?
RS will ONLY be nil if the SQL is malformed, in which case the DB will have an error, which you need to check as it is the only method to help determine WHY it is malformed.

ok… one other situation where RS would be NIL… and that is if you never execute the statement at all

which goes to support exactly what I have been saying, Thank you.

Also, make sure that you are actually opening a connection to your database.

if not ibssts.Connect then // Database connection failed end