Solved

sql statement for access database from vb.net

Posted on 2009-04-01
6
173 Views
Last Modified: 2012-05-06
I keep getting an error when trying to get data from an access database when I use the order by clause - ierrorinfo.getdescription failed.  Any ideas?
0
Comment
Question by:ddepuemd
  • 2
  • 2
  • 2
6 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24038308
Perhaps if you posted your SQL and VB code, a solution could be more easily determined.
0
 

Author Comment

by:ddepuemd
ID: 24038336
sql = "select * from tools where job = '5687568' order by position,number"
        Try
            With dbAdaptr
                Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sql, cn)
                cmd.CommandType = CommandType.Text
                .SelectCommand = cmd
                .Fill(ds, "tools")
            End With
        Catch ex As Exception
            Dim str As String = ex.Message
        End Try
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 24038361
Try putting "number" in brackets. "Number" is a reserved word (a data type name) in Access.

sql = "select * from tools where job = '5687568' order by position,[number]"
0
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
LVL 48

Accepted Solution

by:
jpaulino earned 250 total points
ID: 24038393
A number doesn't need commas (if it's a number) and also use kaufmed suggestion about the brackets
sql = "select * from tools where job = 5687568 order by [position],[number]"
 
 
0
 

Author Comment

by:ddepuemd
ID: 24038581
yeah, I realized the key word problem and changed the table field names..
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 24038747
any other problem ?
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question