hi all
I get this error no matter what i try, i know this is caused when no data is matched on my query, what i need to know is how to make it so i can give the user an option to register of not.
this is the error:
Line 72: SqlDataAdapter2.Fill(Dsaccess1)
Line 73: dbtaccessRow = Dsaccess1.dbtaccess.FindByrnumber(rnumber)
Line 74: If dbtaccessRow.IsUsernameNull = True Then
Line 75: Else
Line 76: username = dbtaccessRow.Username
Source File: c:\inetpub\wwwroot\DeviceList\ChkAccess.aspx.vb Line: 74
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
DeviceList.ChkAccess.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\DeviceList\ChkAccess.aspx.vb:74
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750
This is my code, very simple:
User1.Text = User.Identity.Name.Split("\", 2)(1)
user1.text =
Dim rnumber As Integer
Dim dbtaccessRow As Dsaccess.dbtaccessRow
SqlDataAdapter2.SelectCommand.CommandText = _
"select username, dbase, aliasname,mgr from dbtaccess where (username = '" & User1.Text & "') and (dbase = '" & Webdbase & "')"
SqlDataAdapter2.Fill(Dsaccess1)
dbtaccessRow = Dsaccess1.dbtaccess.FindByrnumber(rnumber)
'--
If dbtaccessRow.IsUsernameNull = True Then
'Crashes right here each time. becasue user name in the sql-dB does not match the user1.text
' if i change thr user name in teh db, everything work perfect.
'
'--
Else
username = dbtaccessRow.Username
End If
If AliasName = dbtaccessRow.AliasName.Empty Then
AliasName = User1.Text
Else
username = dbtaccessRow.AliasName
End If
Response.Write(username)
If username = User1.Text Then
User1.Text = "Hello:" + dbtaccessRow.AliasName
passed.Text = "You Have Edit Rights to this record, remember to click submit when done editing."
Server.Transfer("addedit.aspx?recordnumber=" & RecordNumber & "")
Else
User1.Text = "Hello:" + AliasName 'user1.Text
Submitrecord.Disabled = True
DeleteRecord.Disabled = True
passed.Text = "Sorry - You currently do NOT have edit ability.
End If
all i am doing is trying to match on user.identity toa sql-db and if it is not there then show the screen with the submit and delete commands grayed out.
I hope some one can help me.
Thanks all
Rick :)