Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   .NET (http://www.delphipages.com/forum/forumdisplay.php?f=10)
-   -   Delphi .Net question (codegear 2007) (http://www.delphipages.com/forum/showthread.php?t=202235)

douglas 11-14-2008 01:08 AM

Delphi .Net question (codegear 2007)
 
I've started using Delphi for .Net and very good it is too. I have a few web based database applications that work well for submitting data etc via a web browser.

However, I am really getting stuck on something so simple. I have a text box, a button, an sql connection and a detailsview grid. I enter text into the text box, hit the button and perform an sqlcommand query. The search results are shown in the detailsview grid and paging is enabled and sorting is enabled. However, when I click on the next page, instead of paging to the next page the search results are lost completely and the screen goes blank (unless I click the back button where my original search comes back again).

If I put the search directly into the sqldatasource query all works fine, but I don't want to do that as I need my search to be dynamic, eg, user driven by whatever is typed into the text box.

Can anyone here help with delphi for dot net or does anyone know of a good delphi for dot net forum as I can't find one?

thanks

========================================
A point waiting for the correct answer.

thank you

Jon

Norrit 11-14-2008 01:14 AM

RE: Delphi .Net question (codegear 2007)
 
I'm not familiar with the sqldatasource component, but isn't it so that this component has a filter property?
If so, why don't you use this (is also dynamic and user-driven)

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1

douglas 11-14-2008 01:29 AM

RE: Delphi .Net question (codegear 2007)
 
I'll take a look at that later (I'm not near my development pc at present)

It is amazing that I have performed extensive searches on the web for delphi .net database search examples and I can't find any. Makes me wonder if I'm the only one using Delphi for .Net :-)

========================================
A point waiting for the correct answer.

thank you

Jon

douglas 11-14-2008 01:31 AM

RE: Delphi .Net question (codegear 2007)
 
Example of my search code: (I think I actually posted this question a while ago too and no one responded)

SqlDataSource1.SelectCommand:='SELECT id, clientsurname, doctype, title FROM databaseTable1 WHERE (title like ''%'+textbox1.Text+'%'') or (clientsurname like ''%'+textbox1.text+'%'') or (doctype like ''%'+textbox1.text+'%'') or (id like ''%'+textbox1.text+'%'') order by clientsurname, doctype, title';

The above search works fine, but as soon as I click on a heading to sort the column or click on paging to view the next page the screen goes blank. Viewstate is enabled for all controls. This really has me stumped.

========================================
A point waiting for the correct answer.

thank you

Jon

Norrit 11-14-2008 02:36 AM

RE: Delphi .Net question (codegear 2007)
 
Well, since you can reproduce it easily you could do some debugging on what point it fails (most likeley this is the point, but could be somewhere else, I don't know).
What worries me on your code is if the textbox1.text = ''. What are you doing there ???

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1

douglas 11-14-2008 02:42 AM

RE: Delphi .Net question (codegear 2007)
 
"if the textbox1.text = '' "

Where did you see that in the code?

========================================
A point waiting for the correct answer.

thank you

Jon

douglas 11-14-2008 03:00 AM

RE: Delphi .Net question (codegear 2007)
 
I just found a bit of code on another site which suggests adding sqldatasource1.databind() after my sqlcommandtext, even though my dataasource is already bound.

I'll give it a go later.

========================================
A point waiting for the correct answer.

thank you

Jon

Norrit 11-14-2008 04:10 AM

RE: Delphi .Net question (codegear 2007)
 
I didn't see that in your code, I was just wondering what would happen with your query if your textbox1.text is empty. You'll get a very useless query (LIKE "%%"), which tells you to search no records I guess (%% will become %).

What I meant to tell you, there are more things that you should look into... And I still didn't got an answer on the debugging steps you've taken...

Objective reality is a delirium caused by lack of alcohol in blood.
There is no place like 127.0.0.1

douglas 11-14-2008 04:19 AM

RE: Delphi .Net question (codegear 2007)
 
I have a statement that says if textbox1.text='' then exit so it basically does nothing.

Debugging, not extensively as yet. I will have a go later tonight and let you know.

========================================
A point waiting for the correct answer.

thank you

Jon

douglas 11-14-2008 03:36 PM

RE: Delphi .Net question (codegear 2007)
 
At last, several hours later I've cracked it.

Using parameters to dynamically create the SQL search string works and the paging is now as it should be.

========================================
A point waiting for the correct answer.

thank you

Jon


All times are GMT. The time now is 10:09 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.