suttonturtle
New Member
Do While Not objRS.EOF<BR>For Each objField In objRS.Fields<BR>If objField("Userid").Value=http://aspmessageboard.com/archive/index.php/TextBox1.Text And objField("Username").Value=TextBox2.Text Then //error is in this line<BR> End If<BR> Next<BR> objRS.MoveNext()<BR> Loop<BR> <BR>this is a part of my login and password authentication program.If i want to compare the value of userid from the database and the value entered by the user, How will I do that? I have problem in the third line of the program above. I know its wrong but how can that be replaced.TextBox1.Text and TextBox2.Text are the values entered by the user.<BR><BR>Thx in advance<BR>PhilipNot sure but I think you need to convert the objField("Userid").value to type String. Its not a variant like in classic asp. Try this..<BR><BR>if Ctype(objField("UserId").value,String)=TextBox1.Text then ' TextBox1.Text is of type string already<BR><BR>End ifPlease post your error... if its a type error that isnt displayed unless you put debug="true" in the <% @page directiveInvalid number of parameters. <BR>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <BR><BR>Exception Details: System.Reflection.TargetParameterCountException: Invalid number of parameters.<BR><BR>thanks.k that would be an error with the objField object you are using. I didnt notice before but you are trying to access it through the field object not the recordset object. Im assuming that your using the old adodb.recordset... It should be <BR><BR>If objRs("UserId").Value .... ''<BR><BR>check out the documentation on the new sqlDataReader and oleDbDataReader and the dataset. These have replaced the older recordset in .NETAfter all this I should have just recommended you to do it differently. It looks like you are looping through the whole recordset comparing values.. Why do all that... just do something like this...<BR><BR><BR>sql = "select * from table where username='" & username & "' AND password = '" & password "'"<BR><BR>''Old ado way...<BR>set rs = conn.execute(sql)<BR>if not rs.eof then ''user exists<BR><BR>else ''user doesnt exists<BR><BR>end if<BR><BR><BR>''Ado.net way<BR><BR>''Open connection and initilize Command object<BR>conn.open()<BR>Dim objCommand as New OleDbCommand(sql,conn)<BR>''Create Reader object<BR><BR>Dim objReader as oleDBdataReader = OleDbCommand.ExecuteReader()<BR><BR>if objReader.read() then ''read method returns true if record exists and moves it to first record<BR><BR>''Add success code<BR><BR>else ''<BR> ''Add fail code<BR>end if<BR>-
