Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working on my first page and SQL commands

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I am trying to connect to a database and need to have two sql statements for my query incase I would have an EOF error. Right now I am getting an error message on this script. How would I fix this?

Public Sub Page_Load(Source as Object, E As EventArgs)
if Not IsPostBack Then

Dim dbconn As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;")

Dim selectCMD As SqlCommand = New SqlCommand("Select * from employeeinfo where userID = '" & request.servervariables("AUTH_USER") & "'", dbconn)
if selectCMD.EOF
selectCMD = New SqlCommand("Select * from employeeinfo where userID = 'AM1ST_DOMAIN\" & request.servervariables("AUTH_USER") & "'", dbconn)
end if
selectCMD.CommandTimeout = 30

Dim empDA As SqlDataAdapter = New SqlDataAdapter
empDA.SelectCommand = selectCMD

dbconn.Open()

Dim empDS As DataSet = New DataSet
empDA.Fill(empDS, "employeeinfo")
dbconn.Close()
End If
End Sub
 
BC30456: 'EOF' is not a member of 'System.Data.SqlClient.SqlCommand'.

 
try this:

Dim selectCMD As SqlCommand = New SqlCommand()
selectCMD.CommandText = "Select * from employeeinfo where userID = '" & request.servervariables("AUTH_USER") & "'"
selectCmd.Connection = dbconn

if selectCMD.ExecuteNonQuery() = 0 then
selectCMD.CommandText = "Select * from employeeinfo where userID = 'AM1ST_DOMAIN\" & request.servervariables("AUTH_USER") & "'"

end if


hth
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top