Is this okay to do, or should I do it a different way
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim selectCMD1 As SqlCommand = New SqlCommand()
selectCMD1.CommandText = "Select * from employeeinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
Dim empDA As SqlDataAdapter = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
Dim empDS As DataSet = New DataSet
empDA.Fill(empDS, "employeeinfo"
dbconn1.Close()
selectCMD1.CommandText = "Select * from timeoffbene where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "timeoffbene"
dbconn1.Close()
selectCMD1.CommandText = "Select * from familyinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "familyinfo"
dbconn1.Close()
selectCMD1.CommandText = "Select * from moneyinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "moneyinfo"
dbconn1.Close()
I had one before, and now when I do this when I load the page I get this error
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 252: dbconn1.Close()
Line 253:
Line 254: loginID1.text = empDS.tables("employeeinfo".Rows(0).Item("loginID"
Dim dbconn1 As SqlConnection = New SqlConnection("server=AM1ST_FS1;database=HRINFO;uid=sa;"
Dim selectCMD1 As SqlCommand = New SqlCommand()
selectCMD1.CommandText = "Select * from employeeinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
Dim empDA As SqlDataAdapter = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
Dim empDS As DataSet = New DataSet
empDA.Fill(empDS, "employeeinfo"
dbconn1.Close()
selectCMD1.CommandText = "Select * from timeoffbene where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "timeoffbene"
dbconn1.Close()
selectCMD1.CommandText = "Select * from familyinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "familyinfo"
dbconn1.Close()
selectCMD1.CommandText = "Select * from moneyinfo where loginID = '" & employee.SelectedItem.Value & "'"
selectCMD1.Connection = dbconn1
selectCMD1.CommandTimeout = 30
dbconn1.Open()
empDA = New SqlDataAdapter
empDA.SelectCommand = selectCMD1
empDS = New DataSet
empDA.Fill(empDS, "moneyinfo"
dbconn1.Close()
I had one before, and now when I do this when I load the page I get this error
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 252: dbconn1.Close()
Line 253:
Line 254: loginID1.text = empDS.tables("employeeinfo".Rows(0).Item("loginID"