473,608 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

accessing a SQL View from VBA

2 New Member
Hello,
I am trying to access the results of a sql view from VBA. When trying to query the results of the view through VBA I get a "Object not found" error. I'm able to query tables, but have difficulty accessing views. Not well versed in SQL but I understand that Views seem to be virtual tables, however I am not sure why I am unable to query. Any suggestions much appreciated. Thanks in advance.
Aug 27 '07 #1
3 2213
fplesco
82 New Member
Hello,
I am trying to access the results of a sql view from VBA. When trying to query the results of the view through VBA I get a "Object not found" error. I'm able to query tables, but have difficulty accessing views. Not well versed in SQL but I understand that Views seem to be virtual tables, however I am not sure why I am unable to query. Any suggestions much appreciated. Thanks in advance.
Hey -

For us to get a clearer picture of your problem, you can post part of your code here.
Aug 28 '07 #2
thekind78
2 New Member
Here is what I'm trying to do in VBA:

query = "Select * from h8888.MaxRate"

Set ado_conn = New ADODB.Connectio n
ado_conn.Connec tionString = "ODBC;DRIVER=SQ L Server;" & "DSN=" & dsn & ";" & Db & ";" & uid
ado_conn.Open
Set ado_rs = New ADODB.Recordset


Set xlSht = ThisWorkbook.Sh eets("Rawdata")
xlSht.Range("A1 :H6000").ClearC ontents
ado_rs.Open query, ado_conn
xlSht.Range("A1 ").CopyFromReco rdset ado_rs
ado_rs.Close
ado_conn.Close
Set ado_rs = Nothing
Set ado_conn = Nothing

The code fails when trying to send the query to the server. It receives an "Invalid Object Name" regarding the "h8888.MaxR ate" table I am trying to access. This table is actually a view. I am not sure as to the exact specifics between a view and a table, however, the code above works perfectly for tables. Any thoughts? Much appreciated.
Aug 28 '07 #3
fplesco
82 New Member
Here is what I'm trying to do in VBA:

query = "Select * from h8888.MaxRate"

Set ado_conn = New ADODB.Connectio n
ado_conn.Connec tionString = "ODBC;DRIVER=SQ L Server;" & "DSN=" & dsn & ";" & Db & ";" & uid
ado_conn.Open
Set ado_rs = New ADODB.Recordset


Set xlSht = ThisWorkbook.Sh eets("Rawdata")
xlSht.Range("A1 :H6000").ClearC ontents
ado_rs.Open query, ado_conn
xlSht.Range("A1 ").CopyFromReco rdset ado_rs
ado_rs.Close
ado_conn.Close
Set ado_rs = Nothing
Set ado_conn = Nothing

The code fails when trying to send the query to the server. It receives an "Invalid Object Name" regarding the "h8888.MaxR ate" table I am trying to access. This table is actually a view. I am not sure as to the exact specifics between a view and a table, however, the code above works perfectly for tables. Any thoughts? Much appreciated.
You may try creating a view without a dot or try using one word VIEW name.
Aug 30 '07 #4

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

Similar topics

2
2072
by: Darren Smith | last post by:
I am having a great deal of difficulty accessing individual fields generated from a Sql Server 7 view. When I specify the actual field name, I get the error: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) The column prefix 'inventory_hardware' does not match with a table name or alias name used in the query.
2
7541
by: matthias | last post by:
assume: user a has the table tab_a user b has select-right on the table tab_a an creates the view view_b create view view_b as select * from a.tab_a; this works fine and b can see the content of the table tab_a.
3
4312
by: prodirect | last post by:
Hi all, I hope someone can help me. I've recently created a database and wanted to put it up on an ftp sight so that multiple people could access the same tables at the same time from different geographical locations. I have been completely unsucessful in acheiving this goal so far however. Things I have tried: Create a shortcut to ftp sight via browser then tried to map local drive to
2
1807
by: DanB | last post by:
I am using VB DotNet Std Edition and am writing a web application that needs to read and write to an password protected database. The mdb files reside in a folder (fpdb) under the localhost (c:\inetpub\wwroot) Within the IDE I can view the data using the server explorer and I use that same oledb connection for the web form. I have tried accessing a non-password protected db in the same folder using
1
3117
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
5
3898
by: Mike | last post by:
I'm having trouble accessing SQL2005 Standard Edition as a second instance of SQL Server where the first instance is SQL 2000 Enterprise Edition. I installed SQL 2005 as a named instance "SQL2005". The server is running Windows 2000 SP4 ON A 32-Bit machine. When I look in Services I see the SQL Server (SQL2005), SQL Server Agent (SQL2005) services there. I went into SQL Server Configuration manager and disabled the named pipes protocol...
2
2143
by: le0 | last post by:
guys, this is my first time to deploy website to the server, but every time i access the page this error always appears. --------------------------------------------------------------------------------------------- Server Error in '/sample' Application. -------------------------------------------------------------------------------- The Microsoft Jet database engine cannot open the file
10
3917
by: amazon | last post by:
Our vender provided us a web service: 1xyztest.xsd file... ------------------------------------ postEvent PostEventRequest ------------------------------------- authetication authentication eventname string source string ID string
2
1254
by: kyosohma | last post by:
Hi All, I need to access a Microsoft SQL database View. Is there a way to do this with Python? I have done a fair share of "googling" and found nothing on accessing Views, just executing SQL, which I already know how to do. I am running Windows XP, Python 2.4. Thanks a lot!
0
8503
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8164
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6017
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5489
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3977
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4039
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2482
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1613
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1345
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.