Can you please post the select where you are retrieving your user? Note that Postgres is case-sensitive. You might have built your table differently in dev and prod. Such slight differences can easily be overlooked.
Greg, an apology for not explain well.
Indeed, XOJO Cloud works perfectly.
The problem, I do not know what is happening in this particular issue: when it makes a query to verify if the user exists.
The code does not send any errors. But it never finds the user, knowing that it exists in the table.
Note.- it works perfectly with my local database.
Look this code:
if DBlink = nil then
DBLink = New PostgreSQLDatabase
#If TargetXojoCloud Then
' CLOUD DB
DBlink.host = "localhost"
DBlink.Port = 5432
'DBlink.DatabaseName = "MEDICS_DB"
DBlink.DatabaseName = "postgres"
DBlink.Username = "dbadmin"
DBlink.Password = "XXXXXXXXXXXXXX"
Var sql As String
sql = "SELECT * FROM Tab_Users where cUser_Name=$1;"
Var ps As PostgreSQLPreparedStatement
Var rs As RecordSet
ps = Session.DBlink.Prepare(sql)
ps.Bind(0, "Loreto_R")
ps.SQLExecute
if Session.DBlink.Connect = true then
rs = ps.SQLSelect
Var Getpass As String = rs.Field("cUser_Password")
MessageBox(Getpass)
else
Messagebox ("Error")
end if
#Else
' LOCAL DB
DBlink.host = "localhost"
DBlink.Port = 5432
DBlink.DatabaseName = "MEDICS_DB"
DBlink.Username = "postgres"
DBlink.Password = "XXXXXXXXXXXXXX"
#EndIf
ok, so in your code, you are telling it to use the “postgres” database, but that one is completely empty (as it should be because it’s for postgresql to manage itself.
Also, in the future, please be more careful about pasting code to the forum which contains passwords. I replaced yours with X’s in your code example.
Greg: " ok, so in your code, you are telling it to use the “postgres” database, but that one is completely empty (as it should be because it’s for postgresql to manage itself.
I just ran your query in my PostgreSQL client and it works just fine."
I did this, to test if I can connect to one base or another.
I made the change you suggest. Xojo cannot connect.
He sends me an error. "FATAL: database "MEDICS_DB" does not exist"
If DBlink = nil Then
DBLink = New PostgreSQLDatabase
MessageBox ("1. Dblink no es nulo")
#If TargetXojoCloud Then
MessageBox("2. Cloud")
' CLOUD DB
DBlink.host = "localhost"
DBlink.Port = 5432
DBlink.DatabaseName = "MEDICS_DB"
DBlink.Username = "dbadmin"
DBlink.Password = "Password"
Try
Session.DBlink.Connect
Catch Err As DatabaseException
Messagebox(Err.Message)
End Try
Var sql As String
sql = "SELECT * FROM Tab_Users where cUser_Name=$1;"
Var ps As PostgreSQLPreparedStatement
Var rs As RecordSet
ps = Session.DBlink.Prepare(sql)
ps.Bind(0, "Loreto_R")
ps.SQLExecute
Messagebox("3. Exec")
If Session.DBlink.Connect = true then
MessageBox("True")
rs = ps.SQLSelect
Var Getpass As String = rs.Field("cUser_Password")
MessageBox("Final")
MessageBox(Getpass)
Else
Messagebox ("Error !!!!")
End if
#Else
MessageBox("Local")
' LOCAL DB
DBlink.host = "localhost"
DBlink.Port = 5432
DBlink.DatabaseName = "MEDICS_DB"
DBlink.Username = "postgres"
DBlink.Password = "Password"
#EndIf
If DBlink.Connect = false Then
Messagebox ("Se ha perdido o no se ha podido establecer la conexiĂłn con la base de datos."+EndOfLine+EndOfLine+"Revise su conexiĂłn a internet."+EndOfLine+EndOfLine+DBlink.ErrorMessage)
Else
MessageBox("Conectado")
lConnected = True
End If
End if