Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Can't fetch row...
icon9.gif  Can't fetch row... [message #14287] Thu, 21 February 2008 18:09 Go to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
What I need is a user/pwd validation, my table is defined with the schema:

TABLE_(users)
   SERIAL_ (id) PRIMARY_KEY
   STRING_ (user, 30) NOT_NULL
   STRING_ (realname, 30) NOT_NULL
   STRING_ (passwd, 30) NOT_NULL
END_TABLE


The validation is:

void LoginWindow::BtnOkPush()
{
	Sql sql(*(G_STATE->GetPsqlSession()));
	sql*Select(SqlAll()).From(users)
		.Where(user == (String)editLoginName.GetData() 
		&& passwd == (String)editPassword.GetData() );
	
	if (!sql.Fetch())
		Exclamation ("Incorrect pass and/or username.");
	else
	{
		G_STATE->SetCurrentUser(String(sql[realname]));
		PromptOK("Welcome [* " + String(sql[realname]) + "]");
	}
}



The validation works in the sense that entering an invalid user/pwd combination displays the proper message. But when you enter data for a row that exists, the Welcome message appears without the name (I mean, seems that sql[realname] is empty!).

Any ideas?

P: How I can trace SQL execution?

[Updated on: Thu, 21 February 2008 18:10]

Report message to a moderator

Re: Can't fetch row... [message #14288 is a reply to message #14287] Thu, 21 February 2008 18:40 Go to previous messageGo to next message
indiocolifa is currently offline  indiocolifa
Messages: 49
Registered: January 2008
Location: Argentina
Member
I've discovered that I can refer successfully with sql[0],sql[1]... but not with sql[username], for example.

How I can refer to field names instead of numbers?
Re: Can't fetch row... [message #14306 is a reply to message #14288] Fri, 22 February 2008 10:11 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
indiocolifa wrote on Thu, 21 February 2008 12:40

I've discovered that I can refer successfully with sql[0],sql[1]... but not with sql[username], for example.

How I can refer to field names instead of numbers?



IMO your .sch inclusion is wrong, that is the most likely reason. But we need testcase for further advice.

Also, it is better to have upper-case column names, to avoid clashes with e.g. local variables.

Mirek
Previous Topic: PostgreSQL Session.Open Leak??
Next Topic: How to save the DB data to another SQLite db file in HomeBudget?
Goto Forum:
  


Current Time: Mon Apr 29 04:27:47 CEST 2024

Total time taken to generate the page: 0.03336 seconds