hi...i am working on visual basic 6 and i need to pass the value to the database MySQL via ODBC, it is working fine juz leaving a small bug here, the code shown below:
If player X wins, data below will be stored at MySQL:

blnAddMode = True
rs.AddNew
rs!Player = Trim("X")
rs!Date = Now
rs!Status = Trim("Player X Win")
rs.Update
blnAddMode = False
rs.Close
rs.Open

However i still have the level chosen by the user need to add to the same row:

| NULL   | NULL                 | NULL         | Mindless |
| X      | 3/30/2008 7:51:53 PM | Player X Win | NULL     |
| NULL   | NULL                 | NULL         | Mindless |
| O      | 3/30/2008 7:52:53 PM | Player O Win | NULL     |
| NULL   | NULL                 | NULL         | Mindless |
| X      | 3/30/2008 7:53:10 PM | Player X Win | NULL     |
| NULL   | NULL                 | NULL         | Mindless |
| O      | 3/30/2008 7:54:49 PM | Player O Win | NULL     |
| NULL   | NULL                 | NULL         | Mindless |
| O      | 3/30/2008 7:54:55 PM | Player O Win | NULL     |
| NULL   | NULL                 | NULL         | Mindless |
| O      | 3/30/2008 7:54:59 PM | Player O Win | NULL     |

it seems to be in different row, how can i make it to the same row? thanks
+--------+----------------------+--------------+----------+

Recommended Answers

All 2 Replies

Instead of using addnew ,you need to use Edit .

In simple terms instead using Insert you need to Update the existing record.

hi..i also facing the same problem, here i simplify what i met here:

To establish the connection in form, i use this:

Dim strConnect As String
    strConnect = "dsn=evan"
    Set connPM = New ADODB.Connection
    connPM.CursorLocation = adUseClient
    connPM.Open strConnect
    Set rs = New ADODB.Recordset
    rs.CursorType = adOpenStatic
    rs.CursorLocation = adUseClient
    rs.LockType = adLockPessimistic
    
    rs.Source = "Select Player, Date, Status, Level from tictactoe"
    rs.ActiveConnection = connPM
    rs.Open

When any player win at particular time, i need to show in database, here it is:

blnAddMode = True
rs.AddNew
rs!Player = Trim("X")
rs!Date = Now
rs!Status = Trim("Player X Win")
rs!Level = Trim("")
rs.Update
blnAddMode = False
rs.Close
rs.Open

However when i want to update the Level column, i cant use rs.Edit as recommended.....
it has been separated into tow different rows where actualli i want them in the same row:

+--------+---------------------+--------------+----------+
| Player | Date                | Status       | Level    |
+--------+---------------------+--------------+----------+
| O      | 4/1/2008 9:55:53 AM | Player O Win |          |
|        | 4/1/2008 9:58:18 AM |              | Mindless |
| O      | 4/1/2008 9:58:20 AM | Player O Win |          |
| O      | 4/1/2008 9:58:25 AM | Player O Win |          |
|        | 4/1/2008 9:58:27 AM |              | Mindless |
|        | 4/1/2008 9:58:28 AM |              | Mindless |
+--------+---------------------+--------------+----------+

to this:

+--------+---------------------+--------------+----------+
| Player | Date                | Status       | Level    |
+--------+---------------------+--------------+----------+
| O      | 4/1/2008 9:55:38 AM | Player O Win |  Mindless        |
| X      | 4/1/2008 9:55:42 AM | Player X Win |    Genius      |
+--------+---------------------+--------------+----------+
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.