Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2007, 09:48 AM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default .NET query

I am trying to use a MS Access Database in an vb.aspx page.

I have written the following two queries.. but they are giving me errors which i am unable to fix.ANy help in this regard would be highly appreciated .

Query 1: Dim sSQL As String = "UPDATE AuthorTable" & _
                             " SET ID ='" & sID & "',Name = '" & sName & "',BookID ='" & sID & "',Date ='" & sDate & ""

It gives me the error: Syntax error in string in query expression '''.
I understand that there is probably a problem with the way I am ending the query. But I do not understand what would be the correct syntax. Please Help.

Query 2:
Dim sSQL As String = "SELECT COUNT(*)" & _
                              "FROM (" & _
                                "SELECT DISTINCT LastName" & _
                                 " FROM Authors" & _
                              "WHERE Month = '" & sMonth & "' AND ID = '" & sID & "')"

Error: Operator '&' is not defined for string "SELECT COUNT(*)FROM (SELECT DIST" and type 'ListItem'.

Would really appreciate a quick response.

Thanks
Reply With Quote
  #2 (permalink)  
Old June 15th, 2007, 06:56 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I hate doing SQL strings like this. Try this for your first query:

Dim sSQL as string = String.Format("Update AuthorTable SET ID ='{0}', Name = '{1}', BookID = '{0}', Date = '{2}'", sID, sName, sDate)

and i dont believe you SQL query is corret in the second account so try this instead

sSql = String.Format("Select count(*) from Authors where lastName in(SELECT DISTINCT lastName from authors where month='{0}' and id = '{1}')", sMonth, sID)

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
Reply With Quote
  #3 (permalink)  
Old June 17th, 2007, 01:30 AM
Friend of Wrox
 
Join Date: Aug 2006
Location: Amman, , Jordan.
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Default

for the first error, check the data type of the fields, and make sure that ur string is right, as for the second one... can u really do anything like that in sql!!! as dparsons said, i really don't think you can do that mate :) .. although i do like the idea :)

Nothing is impossible. The impossible only takes longer. "Digital Fortress, Dan Brown"
Reply With Quote
  #4 (permalink)  
Old June 19th, 2007, 03:36 PM
Registered User
 
Join Date: Jun 2007
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks.. Let me try what you suggested.
well I was able to run the second query in access database and also as a query in a table adapter. So its correct though the problem now is that I want to use the count to decide the number of columns that the table( on the web page) will have.
Is there a way I can include a table adapter in aspx page, use the count variable and include that in a for loop creating rows determined on this count?

i.e for i = 1 to count
{ build a row
and display the last name as a label there)



Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query for ScreenScraping Tech in .NET visit2siva ASP.NET 1.x and 2.0 Application Design 1 December 15th, 2005 12:42 PM
Query for ScreenScraping Tech in .NET visit2siva C# 1 December 7th, 2005 09:44 AM
how to query 2 tables in asp.net method ASP.NET 1.0 and 1.1 Basics 3 March 18th, 2005 04:35 PM
.net Query sindhoor .NET Web Services 1 October 20th, 2003 12:22 PM
.NET XPath query not coming out right perropicante C# 0 June 15th, 2003 10:53 AM



All times are GMT -4. The time now is 08:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.