Solved

System.Runtime.InteropServices.COM

Posted on 2003-10-27
3
1,116 Views
Last Modified: 2007-12-19
I have this error when I run this code

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in GetOrders.exe

Additional information: Invalid object name 'StaffAccountsDB'.


code:
________________________________________________________
Dim PT_dsCn As String
        Dim PT_dsStr As String
        Dim PT_intX As Integer
        Dim PT_X As Integer
        Dim PT_membersRs As ADODB.Recordset
        Dim PT_cn As New ADODB.Connection()


 PT_cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=nax;Initial _ Catalog=Development;Data Source= " & "myserver1" & ";Password=abcd"
        PT_cn.Open()
        PT_membersRs = New ADODB.Recordset()

        Try

        PT_membersRs.Open("Select * FROM StaffAccountsDB", PT_cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)

        'Catch
            MsgBox(Err.Number & " " & Err.Description)
________________________________________________________
0
Comment
Question by:paramanj
  • 2
3 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 75 total points
ID: 9629839
This might mean that you have two databases, and are accessing the wrong one, which is missing the StaffAccountsDB table.
0
 

Author Comment

by:paramanj
ID: 9634063
Thanks for the answer, but I have the right database and table name.  It has to be somting else.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 75 total points
ID: 9634213
First a question:  Why use ADO vs. ADO.NET?

Then a suggestion:  Try using ADOX, setup a Catalog, and examine the Tables property to see if the table exists.

Is this a Windows form project in VB.NET?  Does the user have access to the tables?
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question