Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / ADO.NET / May 2005

Tip: Looking for answers? Try searching our database.

SQL Confusion in DA.Fill()

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Christopher Weaver - 19 May 2005 19:56 GMT
The SQL that I'm sending to my server doesn't work unless I run it through
an interactive tool.

I've done this in VS 2003
   cmd.CommandText = "SELECT * FROM \"tblTasks\" ORDER BY " + OrderBy;
   odbcDA_TaskActivities.SelectCommand = cmd;
   MessageBox.Show(cmd.CommandText);
   dsTaskActivities.Clear();
   odbcDA_TaskActivities.Fill(dsTaskActivities, "Tasks");

The Fill method fails whenever OrderBy contains more than one field.  For
example, this works in the ISQL window of my DBMS controller:
   SELECT * FROM "tblTasks" ORDER BY "AssignTo", "DueDate", "Category",
"SubCategory"

It is also the exact text shown in the MessageBox.Show window from the line
before the Fill call in my code when OrderBy is set to
   "AssignTo", "DueDate", "Category", "SubCategory"   .

But I still get a non-specific system error.  When I set OrderBy to
"uidTask" or "Description" the Fill call fills the DataSet.

Any ideas on this?
Earl - 20 May 2005 06:12 GMT
Wouldn't it be:

"SELECT * FROM  \" + tblTasks + "\  ORDER BY " + OrderBy;

> The SQL that I'm sending to my server doesn't work unless I run it through
> an interactive tool.
[quoted text clipped - 19 lines]
>
> Any ideas on this?
Christopher Weaver - 20 May 2005 16:32 GMT
I see your point, but 'tblTasks' is the literal name of the table on the
back end.

> Wouldn't it be:
>
[quoted text clipped - 23 lines]
>>
>> Any ideas on this?
Rogas69 - 20 May 2005 11:20 GMT
well might be this is the problem with doublequotes.. just guessing but i
had similar problem several yrs ago afair. try to change them to [] brackets
or throw them at all
you can also look what is passed to db in profiler

hth

peter

> The SQL that I'm sending to my server doesn't work unless I run it through
> an interactive tool.
[quoted text clipped - 19 lines]
>
> Any ideas on this?
Christopher Weaver - 20 May 2005 16:33 GMT
I don't know if my server (InterBase 7.5) will tolerate anything less than
double quotes with mixed case identifiers in dialect 3, but I will try it.
Thanks for mentioning the profiler.

> well might be this is the problem with doublequotes.. just guessing but i
> had similar problem several yrs ago afair. try to change them to []
[quoted text clipped - 28 lines]
>>
>> Any ideas on this?
Christopher Weaver - 20 May 2005 17:15 GMT
Rogas69,

When you suggest the use of the profiler, do you mean the SQL Server
profiler that comes with the Enterprise manager?  This only works with MS
SQL Server and I'm constrained by my client to use InterBase.

> well might be this is the problem with doublequotes.. just guessing but i
> had similar problem several yrs ago afair. try to change them to []
[quoted text clipped - 28 lines]
>>
>> Any ideas on this?
Rogas69 - 20 May 2005 17:36 GMT
Well you did not say what database you use in the first post. I assumed that
it was SQL Server somehow. :)
Does InterBase not  have anything to trace queries?

peter
> Rogas69,
>
[quoted text clipped - 34 lines]
>>>
>>> Any ideas on this?
Christopher Weaver - 20 May 2005 18:36 GMT
There are problems there.  The IBConsole tool is fairly good and has a trace
feature, but in its current form it does have a problem connecting to remote
servers, a feature that I need.  The next version of the IBConsole is in
beta but does connect well to remote servers; it does not support
monitorring.  IBExpert, from HK Software has a companion trace and
monitorring tool, but I haven't gotten it to work yet.

> Well you did not say what database you use in the first post. I assumed
> that it was SQL Server somehow. :)
[quoted text clipped - 39 lines]
>>>>
>>>> Any ideas on this?
Christopher Weaver - 30 May 2005 23:24 GMT
Just to put a closing note on this,

The problem lay in that a space found its way into the fieldname between the
first character and the leading double quote.  The font used by the
messagebox is small on my screen and proportional as well, so I didn't
notice it.  FieldName = FieldName.Trim(); did the trick.

Thanks for your help.

> Well you did not say what database you use in the first post. I assumed
> that it was SQL Server somehow. :)
[quoted text clipped - 39 lines]
>>>>
>>>> Any ideas on this?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.