M
MRW
Hello!
I'm an ASPer moving on to .NET. I've been searching the web for my
answer, but I've been, suprisingly, unable to find a good answer. I was
hoping you can help.
Back in ASP, if I wanted to check the db for a record (let's say an
Employee Login), all I would have to do is get the recordset and write:
If objRS.EOF Then
Response.write "No Employee Exists"
Else
Response.write "Welcome " & objRS("FirstName")
End If
And that was nice and pretty. I'm trying to do the same thing with
..NET, and my code looks like:
Dim objAdapter As New OleDbDataAdapter(strSQL, objConnection)
Dim objDataSet As New DataSet()
objAdapter.Fill(objDataSet, "tblEmployees")
If objDataSet.Tables("tblEmployees").Rows.Count = 0 Then
Message.Text = "There is no user with that ID"
Else
Message.Text = "Welcome " +
objDataSet.Tables("tblEmployees").Rows(0)("FirstName")
End If
Does it have to be this LONG. Especially accessing records in this
form:
objDataSet.Tables("tblEmployees").Rows(0)("FirstName")
While in ASP it was simply:
objRS("FirstName")
??
I can't seem to find any info on this area for whatever reason. Any
help on simplifying the process is GREATLY appreciated!
I'm an ASPer moving on to .NET. I've been searching the web for my
answer, but I've been, suprisingly, unable to find a good answer. I was
hoping you can help.
Back in ASP, if I wanted to check the db for a record (let's say an
Employee Login), all I would have to do is get the recordset and write:
If objRS.EOF Then
Response.write "No Employee Exists"
Else
Response.write "Welcome " & objRS("FirstName")
End If
And that was nice and pretty. I'm trying to do the same thing with
..NET, and my code looks like:
Dim objAdapter As New OleDbDataAdapter(strSQL, objConnection)
Dim objDataSet As New DataSet()
objAdapter.Fill(objDataSet, "tblEmployees")
If objDataSet.Tables("tblEmployees").Rows.Count = 0 Then
Message.Text = "There is no user with that ID"
Else
Message.Text = "Welcome " +
objDataSet.Tables("tblEmployees").Rows(0)("FirstName")
End If
Does it have to be this LONG. Especially accessing records in this
form:
objDataSet.Tables("tblEmployees").Rows(0)("FirstName")
While in ASP it was simply:
objRS("FirstName")
??
I can't seem to find any info on this area for whatever reason. Any
help on simplifying the process is GREATLY appreciated!