[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sql Servery Query in .ASP

Posted on 2011-10-07
6
Medium Priority
?
227 Views
Last Modified: 2012-06-27
I have a database called Schedule. Inside that database, I have two tables. One called LogonUser and another called Date. I'm trying to query the LogonUser Table so I can figure out what type of security the logged on user should have. This is what I have so far.

objConn.Open "Driver={SQL Server}; " & "Server=10.144.37.20;Database=Schedule;Uid=Intranet; Pwd=Password123;"

StrSQL = "Select [Security] FROM dbo.LogonUser where [LogonUser] like 'MyuserId'"
Set objConn.Execute (StrSQL)

Open in new window


What i have so far works, but what I need is to be able to do something like the following:

Response.write Security

Open in new window

(So I can output the type of security the user should have)

This code is in VBS. Hopefully I was able to describe what i'm trying to accomplish.

0
Comment
Question by:Darkejo1
  • 3
  • 3
6 Comments
 
LVL 61

Expert Comment

by:HainKurt
ID: 36932338
try:

dim rs
set rs = objConn.Execute (StrSQL)
Response.write(rs("Security"))
0
 

Author Comment

by:Darkejo1
ID: 36932636
I added the code as shown below. This is what the code looks like.
strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like 'usdarkejo'"
 set objRS = objConn.Execute (strSQL)
Response.write(objRS("Security1")) 

Open in new window


I receive this message

ADODB.Field error '80020009' 

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record. 

/app/jdschedule/Default.asp, line 0 

Open in new window

Database
0
 

Author Comment

by:Darkejo1
ID: 36932664
The 3rd line should look looke like this

Response.write(objRS("Security"))

Open in new window


I apologize for the typo.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 61

Expert Comment

by:HainKurt
ID: 36932683
there is no objRS("Security1")
it should be objRS("Security")

and make sure you have that record...  

strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like 'usdarkejo'"

-->

starts with

strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like 'usdarkejo*'"
strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like 'usdarkejo%'"

includes

strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like '*usdarkejo*'"
strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like '%usdarkejo%'"


0
 
LVL 61

Accepted Solution

by:
HainKurt earned 2000 total points
ID: 36932692
looks like there is an extra space in your table next to LogonUser

remove that space and use

strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] like 'usdarkejo'"
-->
strSQL = "SELECT [Security] FROM dbo.Logonuser where [Logonuser] = 'usdarkejo'"
0
 

Author Closing Comment

by:Darkejo1
ID: 36932737
Thanks! Worked like a charm!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month18 days, 3 hours left to enroll

830 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