Hi, Thanks for taking a look.
Im tryig to write a little stock program, and i keep getting the following error
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146825287
HelpLink="C:\Windows\HELP\ADO270.CHM#1240641"
Message="Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
Source="ADODB.Recordset"
at this line of code
rsRecordSet.Source = ("Select * from Suppliers")
Im using
VB 2005 express edition. Can any tell this noob where he has gone wrong, Thanks
Module Module2
Public SupCount As Integer
Public Supplier As String
Public connConnection As ADODB.Connection
Public rsRecordSet As ADODB.Recordset
Public mblnAddMode As Boolean
Public strConnect As String
Public strProvider As String
Public strDataSource As String
Public strDataBaseName As String
Public Sub GetSuppliers()
Supplier = ""
SupCount = 0
strProvider = "Provider= Microsoft.Jet.OLEDB.3.51;"
strDataSource = "C:\"
strDataBaseName = "db1.MDB"
strDataSource = "Data Source=" & strDataSource & _
strDataBaseName
strConnect = strProvider & strDataSource
connConnection = New ADODB.Connection
connConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient
connConnection.Open(strConnect)
rsRecordSet = New ADODB.Recordset
rsRecordSet.CursorType = ADODB.CursorTypeEnum.adOpenStatic
rsRecordSet.CursorLocation = ADODB.CursorLocationEnum.adUseClient
rsRecordSet.LockType = ADODB.LockTypeEnum.adLockPessimistic
rsRecordSet.ActiveConnection = connConnection
rsRecordSet.Source = ("Select * from Suppliers")
rsRecordSet.Open()
rsRecordSet.MoveFirst()
For SupCount = 0 To 2
Supplier = rsRecordSet.Fields(0).Value & " " & rsRecordSet.Fields(1).Value
Form2.ListBox1.Items.Add(Supplier)
Supplier = ""
Next
End Sub
End Module
Error Stack Trace
StackTrace:
at ADODB.RecordsetClass.set_Source(Object pvSource)
at WindowsApplication1.Module2.GetSuppliers() in C:\Users\RDX100\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplicati on1\Module2.
vb:line 29
at WindowsApplication1.Form2.Form2_Load(Object sender, EventArgs e) in C:\Users\RDX100\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplicati on1\Form2.
vb:line 8
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.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.SafeNativeMethods.ShowWindow( HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolea n value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.Show()
at WindowsApplication1.Form3.Button7_Click(Object sender, EventArgs e) in C:\Users\RDX100\Documents\Visual Studio 2005\Projects\WindowsApplication1\WindowsApplicati on1\Form3.
vb:line 119
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 WindowsApplication1.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()