Why am I not able to add New Record?

Results 1 to 3 of 3

Thread: Why am I not able to add New Record?

  1. #1
    Join Date
    Dec 1969

    Default Why am I not able to add New Record?

    Hi All!<BR><BR> I am using this code and when I try to add a new record, it just goes and edits the existing one and does not add new one. Why is this?<BR><BR>If sUserID = "" Then<BR> strSQL = "Select UserID,UserName,PassWord,SLevel From UserAdmin Order By UserID"<BR> Else<BR> strSQL = "Select UserID,UserName,PassWord,SLevel From UserAdmin Where UserID = &#039"& sUserID &"&#039"<BR> End If <BR><BR> Set rsUser = CreateObject("Adodb.Recordset")<BR> rsUser.Open strSQL,gConn,adOpenKeyset,adLockOptimistic,adcmdTe xt<BR> <BR><BR> If rsUser.EOF Then<BR> rsUser.AddNew<BR> rsUser("UserID") = Trim("" & Request.Form("fUserID"))<BR> rsUser("UserName") = Trim("" & Request.Form("fUserName"))<BR> rsUser("PassWord") = Trim("" & Request.Form("fPassWord")) <BR> rsUser("SLevel") = Trim("" & Request.Form("fSlevel"))<BR> rsUser.Update<BR> End If

  2. #2
    Franco Guest

    Default RE: Why am I not able to add New Record?

    You could try leaving out the WHERE part of the SQL statement (why pick a particular existing record if all you&#039re doing is adding a new one?) and maybe using an INSERT statement like<BR><BR>INSERT USERADMIN (UserName, Password) VALUES (@UserName, @Password)<BR><BR>SQL Programming - easy and fun. Who needs hobbies?<BR><BR>F.

  3. #3
    Yahoo Guest

    Default RE: Why am I not able to add New Record?

    &nbsp;<BR>If rsUser.EOF Then<BR>rsUser.AddNew<BR>rsUser("UserID") = Trim("" & Request.Form("fUserID"))<BR>rsUser("UserName") = Trim("" & Request.Form("fUserName"))<BR>rsUser("PassWord") = Trim("" & Request.Form("fPassWord")) <BR>rsUser("SLevel") = Trim("" & Request.Form("fSlevel"))<BR>rsUser.Update<BR>End If<BR><BR>do use rsuser("username") try to move to a variable.<BR>instead of that use like this <BR>UserName = Trim("" & Request.Form("fUserName"))<BR><BR>any problem make respone immedaitely<BR><BR>Thanxs<BR>yahoo<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts