473,404 Members | 2,178 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

problems retrieving data from an access database using vb.net 2003

This is driving me nuts, been at it now for the last week, anyone any ideas on wher im going wrong?

using a list box pipeLB and a date/time picker pDate, im trying to populate the list box with the rows from the database where the date equals the one selected on the date/time picker. This should happen when i click the button showData.

my database is called PressureReadings and the table inside it is called Pipe1Readings, with columns labelled as key,date and pressure. All it keeps throwing is the exception, but i know the database isnt in use as it tells me, it must be in my code somewhere.

heres my code;

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub showData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles showData.Click
  3. Dim fmtStr As String = "{0,8} {1,15} {2,15} " 
  4. Dim i As Integer
  5. Dim tdate As Date
  6. tdate = FormatDateTime(Me.pDate.Value, DateFormat.ShortDate)
  7. 'Place contents of Pressures table into a DataTable
  8. Dim dt As New DataTable
  9. Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = PressureReadings.mdb "
  10. Dim sqlStr As String = "SELECT * FROM Pipe1Readings" ' where date = #" + tdate + "#"
  11. Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, connStr)
  12. Try
  13. dataAdapter.Fill(dt)
  14. Catch
  15. MsgBox("Database Currently in Use - Can't Open")
  16. ' End
  17. End Try
  18. dataAdapter.Dispose()
  19. 'Fill the list box
  20. pipeLB.Items.Add(String.Format(fmtStr, "DATE", "PRESSURE", "KEY"))
  21. For i = 0 To dt.Rows.Count - 1
  22. pipeLB.Items.Add(String.Format(fmtStr, FormatDateTime(dt.Rows(i)(0), _
  23. DateFormat.ShortDate), dt.Rows(i)(1), dt.Rows(i)(2)))
  24. Next
  25. End Sub
  26.  
any help would be most appreciated

sorry about the low points - trying to conserve them - waiting for the student loan cheque to come in so i can buy some more.

again - much appreciated in advance.

Ray
Apr 22 '06 #1
1 5456
I think your connection string is wrong or giving trouble.
I have coppied your code added a few lines and got it to work.

connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Thefolder\thefilename.mdb;User Id=admin;Password=;"
Dim mycon As New System.Data.OleDb.OleDbConnection(connStr)

Dim sqlStr As String = "SELECT * FROM temptable"
Dim dataAdapter As New OleDb.OleDbDataAdapter(sqlStr, mycon)

I basically changed your connection string and first created the connection and then the adapter using a connector rather than a connection string. Makes it easier to debug.
Apr 24 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Nitec Dev | last post by:
Our setup: server1 ASP database running on IIS5, Outlook 2000 and SQL 2000 on Windows 2000. Server2 runs Windows 2000 with Exchange 2000 using CDO 1.2 MAPI Sessions. Clients use IE5/6 and had...
2
by: Joseph Macari | last post by:
I recently installed Office2003 on my computer. I had imported (not linked) a couple of tables from an Access 2000mdb into an Access 2003mdb. I had composed various queries and forms with these...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
5
by: Microsoft | last post by:
Hi, I have Visual Basic .net 2003 (Standard Edition) & SQL Server 2000 Developer Edition. When trying to create a connection in the server explorer from the .net IDE I get a number of problems;...
3
by: Hrvoje Vrbanc | last post by:
Hello all! Scenario: - web server at one location (domain) with VS 2003 - SQL server at a remote location (domain) - VPN connection on port 1433 between the two domains I have no troubles...
17
by: Rico | last post by:
Hello, I am in the midst of converting an Access back end to SQL Server Express. The front end program (converted to Access 2003) uses DAO throughout. In Access, when I use recordset.AddNew I...
5
by: samadams_2006 | last post by:
I'm having a problem in accessing a Microsoft Access Database in a VB.NET Web Application. It's so straight forward, I thought I'd walk you through all the details here: 1) I have a .NET Web...
7
by: rfinch | last post by:
Very new to this but using the MS working with dynamics CRM 3.0 book to run web application to retrieve lead records from CRM 3.0. Have followed the book instructions on page 380-382. But am...
3
by: Earl Anderson | last post by:
One of the users in our departmental db has Read/Write permissions to a particular form. He was able to access and edit the form at will until 2 weeks ago. His current problem was that he was not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.