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
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