Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

select MSSQL view fro ASP

I am having issues selecting from an MSSQL DB view from my ASP.  I recieve the following error message:

Microsoft OLE DB Provider for ODBC Drivers error '80040e37'

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'VIEW_NV390MSG'.

/cco/syseng/eventhelp/EventHelpResults1.asp, line 359

My query is correct and if i switch back to the table the select works fine.  I am using the following to select:

StrSQL="SELECT oncalllabel FROM VIEW_NV390MSG WHERE messageid='" & TecMsgidVal & "'"
Response.Write StrSQL
Set RS1 = Conn.execute(StrSQL)

and my db connect is made as:

ADOConnectStr = "driver={SQL Server};server=XXX;database=HELP;uid=HELP;pwd=HELP;"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open ADOConnectStr
Server.ScriptTimeout = 300

Is what I am trying not possible?


0
kkelley6
Asked:
kkelley6
1 Solution
 
WakieCommented:
Hi kkelley, try this:

StrSQL = "SELECT oncalllabel FROM [VIEW_NV390MSG] WHERE messageid = '" & TecMsgidVal & "'"

OR

StrSQL = "SELECT oncalllabel FROM [VIEW_NV390MSG] WHERE messageid = " & TecMsgidVal & ""

OR

Change the name of your database table, "VIEW_NV390MSG", to something else.

Regards,
Wakie.
0
 
kkelley6Author Commented:
I tried your suggestions but, these are not tables....they are actually mssql views ( if that matters)
0
 
oceanASPCommented:
make sure u have permissions to perform a select query on your database.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
kkelley6Author Commented:
I have previously grant select permission to the db id I am using and public.
0
 
genesysnetCommented:
Can you run the query OK from Query Analyser, logging in as the same user as specified in your ASP application?

Query Analyser may give you a more specific error that makes more sense.
0
 
kkelley6Author Commented:
Hmm... good idea. Actually, i get the same type of message.

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sentryview'.

What does that mean I should do?
0
 
genesysnetCommented:
Can check the view configuration to ensure that you are querying the correct table and that it does not try to select any rows that do not exist...

Sounds like you are trying to select from a table that does not exist.
0
 
genesysnetCommented:
Sorry that should be does not select any columns that do not exist (not rows)
0
 
genesysnetCommented:
Or perhaps (given the invalid objects name - sentryview) the view you are calling is trying to access another view which has not been configured.
0
 
kkelley6Author Commented:
The issue was related to permissions of the view I created.  I did not think to try the same query from the analyser.  Basically, i was able to create the view, was the owner of the view but did not have the ability to select using the view.
0
 
apolloisCommented:
kkelley6,

I am confused about your QA results.  It refers to the object 'sentryview' whereas your ASP code refers to 'VIEW_NV390MSG'

How are these related?

The obvious thing to check is to verify using SQL Server Enterprise Mgr that you have views named 'VIEW_NV390MSG' and 'sentryview'.  Double check the spelling, and the security permissions.

Please run the EXACT same query in the QA as you are using in ASP, and post the results.

Best Regards,
apollois
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now