very urgent-heeeeeeeeeeeelp pleeeeeeeease

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: very urgent-heeeeeeeeeeeelp pleeeeeeeease

  1. #1
    user Guest

    Default very urgent-heeeeeeeeeeeelp pleeeeeeeease

    Hi all,<BR>I have a table. the table has three columns, CustomerName,totalads,totalIncome<BR><BR>I am trying to insert a record into this table.<BR><BR>If the particular CustomerName is already found , I just need to update the other two columns totalads,totalIncome.<BR><BR>If the CustomerName column is not found, then I need to insert a whole new row.<BR><BR>Also, I need to use the lock options in the table, so that no two users can try to update the table at the same time.<BR>how will I do this?<BR><BR>Any help will be appreciated. <BR>

  2. #2
    Persesus Guest

    Default RE: very urgent-heeeeeeeeeeeelp pleeeeeeeease

    First do a SELECT SQL to see if the record exists, If not add one, otherwise just modify the existing one.<BR><BR>Recordlocking is tricky. If you are using MSAccess you will have problems because it can&#039t lock individual records, just pages of them.

  3. #3
    user Guest

    Default attention Persesus!!!!

    Hi Persesus(and all),<BR> thanks for the response. <BR><BR>How will I check if the record exists? <BR><BR>Also, I am not using ms-access. I am using SQL server 7.0.<BR>How will do record locking using sql server 7.0.<BR><BR>Thanks.

  4. #4
    manual Guest

    Default RE: very urgent-heeeeeeeeeeeelp pleeeeeeeease

    Set objConn = Server.CreateObject("ADODB.Connection")<BR>Set objRS = Server.CreateObject("ADODB.Recrodset")<BR>objConn. Open "DSN=customers"<BR><BR>strSQL = "SELECT CustomerName, totalads,totalImcome " & _<BR> "FROM Customers " & _<BR> "WHERE CustomerName = &#039manual&#039"<BR>objRS.Open strSQL, objConn, 1, 3<BR>&#039Or so users can&#039t update at the same time<BR>&#039objRS.Open strSQL,objConn, 1, 2<BR>If Not objRS.EOF Then<BR> blnCustomer_Exists = True<BR>Else<BR> blnCustomer_Exists = False<BR>End If<BR>objRs.Close<BR><BR>If blnCustomer_Exists Then<BR> strSQL = &#039Update Record<BR> objRS.Open strSQL, objConn, 1, 3<BR> & strSQL, objConn 1, 2<BR>&#039Put your code here<BR> objRS.Close<BR>Else<BR> strSQL = &#039New Record<BR> objRS.Open strSQL, objConn, 1, 3<BR> & strSQL, objConn 1, 2<BR>&#039Put your code here<BR> objRS.Close<BR>End If<BR><BR>objConn.Close<BR>Set objRS = Nothing<BR>Set objConn = Nothing

  5. #5
    Persesus Guest

    Default You have my attention.

    Does your web server have the extensions to connect to a database?<BR>Do you have a connection to the database through ASP?

  6. #6
    user Guest

    Default RE: You have my attention.

    Yaa,<BR> I can connect to the database from ASP.

  7. #7
    Persesus Guest

    Default RE: You have my attention.

    You may of seen Manual&#039s response, This is how I would of done it.<BR><BR>set dbconn = server.createobject("adodb.connection")<BR>dbconn. open "provider=sqloledb.1;password=;user id=;initial catalog=DATABASE;data source=SERVER"<BR>&#039replace database with you database name and server with your server name<BR><BR>set rstemp = dbconn.execute("select * from TABLE where customername=&#039CUSTOMERNAME&#039")<BR>if rstemp.eof = false<BR> &#039customer exists<BR> dbconn.execute("update TABLE set TOTALADS=XX, TOTALINCOME=XX where customername=&#039CUSTOMERNAME&#039")<BR>else<BR> &#039customer does not exist<BR> dbconn.execute("insert into TABLE (customername,totalads,totalincome) values (&#039CUSTOMERNAME&#039,TOTALADS,TOTALINCOME)")<BR >end if<BR>(rep<BR>rstemp.close<BR>set rstemp = nothing<BR>&#039replace table with your table name<BR>&#039replace customername, totalads, totalincome with the required values. <BR>&#039i&#039ve assumed totalads, and totalincome are numeric fields, if not put &#039 on either site of the value.<BR><BR>dbconn.close<BR>set dbconn = nothing<BR><BR>&#039 You only need to change the words in UPPERCASE.<BR><BR>Hope it helps<BR>Persesus<BR>

  8. #8
    Thanks, Pers&manual-But Guest

    Default RE: You have my attention.

    Thanks a million Persesus, Manual.<BR><BR>But, will this take care of locking the records also??

  9. #9
    user Guest

    Default Thanks a lot Persesus& manual, but ???

    thanks a million Persesus and Manual,<BR> But, will this take care of locking the records during updation also??

  10. #10
    Persesus Guest

    Default Good Question.

    Maybe Manual can answer your question.<BR><BR>Myself I think you won&#039t have a problem. Not unless you update the record hundreds of times in a short space.

Posting Permissions

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