Solved

Retrieving single piece of data from SQL database

Posted on 2006-11-14
4
194 Views
Last Modified: 2012-06-21
I have this little snippet of code:

        myconnectionstring = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True"
        Dim myconn As New Data.SqlClient.SqlConnection(myconnectionstring)
        myconn.Open()
        Dim objcommand1 As New Data.SqlClient.SqlCommand("SELECT RTRIM(aspnet_ChamberWorkstation.Workstation) AS Expr1 FROM aspnet_ZoneChamber INNER JOIN aspnet_ChamberWorkstation ON aspnet_ZoneChamber.Zone = aspnet_ChamberWorkstation.Zone WHERE (aspnet_ZoneChamber.Chamber = '" & Me.DropDownList1.SelectedValue & "') AND aspnet_ChamberWorkstation.workstation = '" & objWSHNetwork.ComputerName & "'", myconn)
        workstationcheck = objcommand1.ExecuteScalar
        MsgBox(workstationcheck)

I'm trying to pull a single piece of data from the database which DOES exist. When the msgbox triggers, it is suppose to show the name of the workstation is pulls from the database, but in this case the box is just blank. I'm sure it's got something to so with my SQL statement but i can't figure out what i'm doing wrong.

Just as a heads up, objWSHNetwork.ComputerName, pulls the name of the workstation i am running on. I'm trying to do a verification with the database to make sure that the workstation I am currently on is listed as a secure workstation in the SQL database.

Please Help!

Thanks!
0
Comment
Question by:NP2322
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
Comment Utility
Put a breakpoint on Me.DropDownList1.SelectedValue and see what value is being pushed up.

Where in the page lifecycle are you doing this (init, load, prerender...)?

0
 

Author Comment

by:NP2322
Comment Utility
haven't tried using breakpoint yet, but it takes place in a button.
0
 
LVL 6

Expert Comment

by:badalpatel
Comment Utility

i think ur query is not returning any data and thats readon the message box is blank..
try to execute the query in query analyzer and see what happened, is it giving data??
0
 

Author Comment

by:NP2322
Comment Utility
i was able to figure it out. it was definitely in the SQL statement. I was comparing a string to a number in my WHERE clause. IDIOT.

Thanks,
Nikhul
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now