By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,719 Members | 1,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,719 IT Pros & Developers. It's quick & easy.

problem in reading from Access

P: 17
hi friends

i am using vb.net 2005 backend Access am not able to get the data from northwind. its shows error. am very new to vb.net. am trying to fetch data from access and display in the textbox.
Expand|Select|Wrap|Line Numbers
  1.  (vb.net)
  2. Imports System.Data.OleDb
  3.  
  4. Public Class Form1
  5.  
  6.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7.         Dim myDataSet As DataSet
  8.         Dim myConnection1 As New OleDb.OleDbConnection()
  9.         myConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  10.         "Data Source=E:\visualstudio2005\northwind.mdb;"
  11.         Dim mySelectCommand1 As New OleDb.OleDbCommand()
  12.         mySelectCommand1.CommandText = "SELECT Address, City, Region, PostalCode FROM Customers"
  13.         mySelectCommand1.Connection = myConnection1
  14.         Dim myDataAdapter1 As New OleDb.OleDbDataAdapter()
  15.         myDataAdapter1.SelectCommand = mySelectCommand1
  16.         myDataSet = New DataSet("MyNewDataSet")
  17.         myDataAdapter1.Fill(myDataSet)
  18.     End Sub
  19. End Class
  20.  
Regards
vijay
Feb 4 '08 #1
Share this Question
Share on Google+
3 Replies


dip_developer
Expert 100+
P: 648
hi friends

i am using vb.net 2005 backend Access am not able to get the data from northwind. its shows error. am very new to vb.net. am trying to fetch data from access and display in the textbox.
Expand|Select|Wrap|Line Numbers
  1.  (vb.net)
  2. Imports System.Data.OleDb
  3.  
  4. Public Class Form1
  5.  
  6. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  7. Dim myDataSet As DataSet
  8. Dim myConnection1 As New OleDb.OleDbConnection()
  9. myConnection1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  10. "Data Source=E:\visualstudio2005\northwind.mdb;"
  11. Dim mySelectCommand1 As New OleDb.OleDbCommand()
  12. mySelectCommand1.CommandText = "SELECT Address, City, Region, PostalCode FROM Customers"
  13. mySelectCommand1.Connection = myConnection1
  14. Dim myDataAdapter1 As New OleDb.OleDbDataAdapter()
  15. myDataAdapter1.SelectCommand = mySelectCommand1
  16. myDataSet = New DataSet("MyNewDataSet")
  17. myDataAdapter1.Fill(myDataSet)
  18. End Sub
  19. End Class
  20.  
Regards
vijay
what error are you getting???
Feb 4 '08 #2

P: 17
hi friend

am getting error in this line no 17
myDataAdapter1.Fill(myDataSet)
am not able to get the data in the dataset.
plz help me

Regards
vijay
Feb 4 '08 #3

P: 26
It seems like its your connection. Make sure path is correct to mdb file and also use \\ rather than \ or u will just escape the char after the \.

"Data Source=E:\\visualstudio2005\\northwind.mdb;"

should do the trick....

God luck!
Feb 4 '08 #4

Post your reply

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