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

Help With OleDbDataAdapter

P: n/a
hi all(i tried yesterday but it didnt work).
i wrote this code and i get an error msg:
Private Pr_MyCon As System.Data.OleDb.OleDbConnection
Private Pr_DataSet As DataSet
Private Pr_DataAdapter As
System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "..."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the error msg saing:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hello

You could try this, only you will need to change Connection string and Table
name

Dim Pr_MyCon As System.Data.OleDb.OleDbConnection
Dim Pr_DataSet As DataSet
Dim Pr_DataAdapter As System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;User ID=ppr;Initial
Catalog=BMS;Data Source=SERVER1"
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select * from CUSTOMER",
Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")

Regards

Partha

"shachar" <an*******@discussions.microsoft.com> wrote in message
news:28****************************@phx.gbl...
hi all(i tried yesterday but it didnt work).
i wrote this code and i get an error msg:
Private Pr_MyCon As System.Data.OleDb.OleDbConnection
Private Pr_DataSet As DataSet
Private Pr_DataAdapter As
System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "..."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the error msg saing:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

Nov 21 '05 #2

P: n/a
NO, i copied your code and i get the same error msg.
-----Original Message-----
Hello

You could try this, only you will need to change Connection string and Tablename

Dim Pr_MyCon As System.Data.OleDb.OleDbConnection
Dim Pr_DataSet As DataSet
Dim Pr_DataAdapter As System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "Provider=SQLOLEDB.1;IntegratedSecurity=SSPI;Persist Security Info=False;User ID=ppr;InitialCatalog=BMS;Data Source=SERVER1"
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select * from CUSTOMER",Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")

Regards

Partha

"shachar" <an*******@discussions.microsoft.com> wrote in messagenews:28****************************@phx.gbl...
hi all(i tried yesterday but it didnt work).
i wrote this code and i get an error msg:
Private Pr_MyCon As System.Data.OleDb.OleDbConnection
Private Pr_DataSet As DataSet
Private Pr_DataAdapter As
System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "..."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the error msg saing:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

.

Nov 21 '05 #3

P: n/a
Hello

I used the same code to bind to a datagrid.
The code below is working.
Dim Pr_MyCon As System.Data.OleDb.OleDbConnection

Dim Pr_DataSet As DataSet

Dim Pr_DataAdapter As System.Data.OleDb.OleDbDataAdapter

Pr_MyCon = New System.Data.OleDb.OleDbConnection

Pr_DataSet = New DataSet("Temp")

Pr_MyCon.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;User ID=ppr;Initial
Catalog=BMS;Data Source=APHRODITE"

Pr_DataAdapter = New OleDb.OleDbDataAdapter("select * from CUSTOMER",
Pr_MyCon)

Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")

Me.DataGrid1.SetDataBinding(Pr_DataSet, "MyTable")
Regards
Partha

"shachar" <an*******@discussions.microsoft.com> wrote in message
news:1a****************************@phx.gbl...
NO, i copied your code and i get the same error msg.
-----Original Message-----
Hello

You could try this, only you will need to change

Connection string and Table
name

Dim Pr_MyCon As System.Data.OleDb.OleDbConnection
Dim Pr_DataSet As DataSet
Dim Pr_DataAdapter As System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString

= "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;User

ID=ppr;Initial
Catalog=BMS;Data Source=SERVER1"
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *

from CUSTOMER",
Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")

Regards

Partha

"shachar" <an*******@discussions.microsoft.com> wrote in

message
news:28****************************@phx.gbl...
hi all(i tried yesterday but it didnt work).
i wrote this code and i get an error msg:
Private Pr_MyCon As System.Data.OleDb.OleDbConnection
Private Pr_DataSet As DataSet
Private Pr_DataAdapter As
System.Data.OleDb.OleDbDataAdapter
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet("Temp")
Pr_MyCon.ConnectionString = "..."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
the error msg saing:"An unhandled exception of
type 'System.Data.OleDb.OleDbException' occurred in
system.data.dll"

.

Nov 21 '05 #4

P: n/a
Shachar,

To get more information you can try this

The code you use cannot be, therefore I assume that the private declaration
are outside a method and the rest in it.

Private Pr_MyCon As System.Data.OleDb.OleDbConnection
Private Pr_DataSet As DataSet
Private Pr_DataAdapter As
System.Data.OleDb.OleDbDataAdapter

Method sub or function
Pr_MyCon = New System.Data.OleDb.OleDbConnection
Pr_DataSet = New DataSet
Pr_MyCon.ConnectionString = "..."
Pr_DataAdapter = New OleDb.OleDbDataAdapter("select *
from MyTable", Pr_MyCon)
try
Pr_DataAdapter.Fill(Pr_DataSet, "MyTable")
catch ex as oledb.oledbexception
messagebox.show(ex.tostring)
catch ex as exception
end try
///
above typed in this message not tested and maybe with typos.

With this you get more information from the problem.
I assume it is a windowform application otherwise you should use the
console.write when you use VSNet or an extra label to show the ex.message on
a page when you use the notebook.

I hope this helps?

Cor
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.