Please check this out. I hope this might help you
news:7403F91E-C3DC-4C41-A1D5-8E0AC9AAB899@microsoft.com...
Quote:
Hi,
I have a simple code where I am trying to capture a recordset in a grid
veiw
using a button click event. Data is connected to sql server 2000. However,
I
am getting error at the line adapter.fill(dt1) I would appreciate any help
on
this matter. Thanks
>
CODE:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button6.Click
'Create a Recordset from all the records in the Orders table.
>
Dim Connection As New OleDbConnection("Provider=SQLOLEDB;Data
Source=localhost; Initial Catalog=Northwind;Integrated Security=True")
Dim adapter As New OleDbDataAdapter("select * from Orders",
Connection)
Dim dt1 As New DataTable("Orders")
adapter.Fill(dt1)
dg1Orders.DataSource = dt1
MessageBox.Show(dt1.Rows.Count)
>
Exit Sub
>
Err_Handler:
MsgBox(Err.Description, vbCritical, "Error: " & Err.Number)
End Sub
>
The following is the copy paste of the exception detail code:
>
System.Data.OleDb.OleDbException was unhandled
ErrorCode=-2147217887
Message="No error message available, result code:
DB_E_ERRORSOCCURRED(0x80040E21)."
Source="System.Data"
StackTrace:
at
System.Data.OleDb.OleDbConnectionInternal..ctor(Ol eDbConnectionString
constr,
OleDbConnection connection)
at
System.Data.OleDb.OleDbConnectionFactory.CreateCon nection(DbConnectionOptions
options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection
owningObject)
at
System.Data.ProviderBase.DbConnectionFactory.Creat eNonPooledConnection(DbConnection
owningConnection, DbConnectionPoolGroup poolGroup)
at
System.Data.ProviderBase.DbConnectionFactory.GetCo nnection(DbConnection
owningConnection)
at
System.Data.ProviderBase.DbConnectionClosed.OpenCo nnection(DbConnection
outerConnection, DbConnectionFactory connectionFactory)
at System.Data.OleDb.OleDbConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(Data Set dataset,
DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String
srcTable,
IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable[] dataTables,
Int32 startRecord, Int32 maxRecords, IDbCommand command, CommandBehavior
behavior)
at System.Data.Common.DbDataAdapter.Fill(DataTable dataTable)
at ExcelAutomation1.Form1.Button6_Click(Object sender, EventArgs e)
in C:\ExcelAutomation1\ExcelAutomation1\Form1.vb:line 287
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG&
msg)
at
System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32
reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
at
Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[]
commandLine)
at ExcelAutomation1.My.MyApplication.Main(String[] Args) in
17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
at System.Threading.ExecutionContext.Run(ExecutionCon text
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
>