yaniv Posted June 9, 2004 Posted June 9, 2004 I"m trying to read a cookie from the clinet machine using the code: If not Request.Cookies("shoresh")("newmasinblogs") is nothing Then If Request.Cookies("shoresh")("newmasinblogs") = "כן" Then massagenum.Text = dataset.Tables("massages").Rows.Count CheckBox1.Checked = True End If End If the problem is that i get error massege: "Object reference not set to an instance of an object." i just can't solve the problem, i tried to rewrite the cookies, i tried to set it to nothing and then to rewrite it... nothing working. do somebody knows what the problem is? Quote
bob01900 Posted June 9, 2004 Posted June 9, 2004 Try changing the first line to the following: If Not Request.Cookies("shoresh") Is Nothing AndAlso Request.Cookies("shoresh")("newmasinblogs") Is Nothing Then Not sure if this helps. Quote
Administrators PlausiblyDamp Posted June 9, 2004 Administrators Posted June 9, 2004 Does the dataset and the Table "massages" exist? IF so what is the value of dataset.Tables("massages").Rows.Count if you step through the code in the debugger? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
yaniv Posted June 9, 2004 Author Posted June 9, 2004 it is more then 0, it's 3 or 4. i get the error massage even in the first checking of the cookies... (if request.cookies... is nothing....) Quote
yaniv Posted June 9, 2004 Author Posted June 9, 2004 may be when i set the cookies to nothing i caused a problem? i tried to import "server.web.httpcookies", it is just not working!!! Quote
Administrators PlausiblyDamp Posted June 9, 2004 Administrators Posted June 9, 2004 How about if you did If (not Request.Cookies("shoresh") is nothing) andalso (not Request.Cookies("shoresh")("newmasinblogs") is nothing) Then If Request.Cookies("shoresh")("newmasinblogs") = "כן" Then massagenum.Text = dataset.Tables("massages").Rows.Count CheckBox1.Checked = True End If End If Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
yaniv Posted June 9, 2004 Author Posted June 9, 2004 that did it!!! thanks a lot, both. just can't understand the different.... oh, that machines. :) Quote
Administrators PlausiblyDamp Posted June 9, 2004 Administrators Posted June 9, 2004 in your original code If not Request.Cookies("shoresh")("newmasinblogs") is nothing it will try to evaluate Cookies("shoresh")("newmasinblogs") but if Cookies("shoresh") is nothing then it will fail, doing it in two stages makes sure both parts aren't nothing. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.