Reading Access slots 1 by 1 in loop HELP

Results 1 to 2 of 2

Thread: Reading Access slots 1 by 1 in loop HELP

  1. #1
    Join Date
    Dec 1969

    Default Reading Access slots 1 by 1 in loop HELP

    Alright, this is what i am trying to do. I want to read info from a database one slot at a time. I keep updating the select command and when i check the UserId (autonumber), it seems to loop fine ( as far as readng info goes). However when i want to read any other slot from this database in the loop it doesnt work at all. I know theres some smart guy/girl out there :)<BR><BR>Dim count As Integer<BR> Dim count2 As Integer<BR> Dim count3 As Integer<BR><BR> Dim intBuf As Int16 = FreeFile()<BR> Dim strFileData As String<BR> Dim strFileDataBase As String<BR><BR> FileOpen(intBuf, "C:Documents and SettingsOwnerDesktopDocsword1.txt", OpenMode.Input)<BR> count3 = 0<BR><BR> Try<BR> Do While count3 &#060; 1<BR> count = count + 1<BR> cmd = New OleDbCommand("SELECT * From tblusers WHERE UserID = " & count, con)<BR> objCmd.SelectCommand = cmd<BR> objCmd.Fill(ds, "tblusers")<BR> strFileDataBase = ds.Tables("tblusers").Rows(0)(1)<BR> Label1.Text += ds.Tables("tblusers").Rows(0)(1) & " : " & ds.Tables("tblusers").Rows(1)(0) & " "<BR> ds.Tables("tblusers").Clear()<BR> Try<BR> Do Until EOF(intBuf)<BR> strFileData = LineInput(intBuf)<BR> If strFileDataBase = strFileData Then<BR> Label2.Text += strFileData & " : "<BR> End If<BR> Loop<BR> Catch Err As System.IO.IOException<BR> MessageBox.Show(Err.Message, "File could not be read!", MessageBoxButtons.OK, MessageBoxIcon.Error)<BR> End Try<BR> Loop<BR> &#039; Dim dr As DataRow = ds.Tables("tblusers").NewRow()<BR> &#039; dr(0) = ""<BR> &#039; ds.Tables("tblusers").Rows.Add(dr)<BR> &#039;objCmd.InsertCommand = New OleDbCommand()<BR> &#039;objCmd.InsertCommand.CommandText = "Insert INTO tblusers(PhoneNumber) VALUES (&#039;" & strFileData & "&#039;)"<BR> &#039;objCmd.InsertCommand.Connection = con<BR> &#039;objCmd.Update(ds, "tblusers")<BR> Catch Err As OleDbException<BR><BR> Catch Err As IndexOutOfRangeException<BR> MessageBox.Show("The file is done.", "Status Report", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)<BR> count3 = 2<BR> &#039;Label1.Text = count2<BR> FileClose(intBuf)<BR> End Try<BR><BR> FileClose(intBuf)<BR> End Sub<BR><BR>All the connections have al;ready been made.

  2. #2
    Join Date
    Dec 1969

    Default Oh, blech!!!

    And what will you do when there are 13,297 UserID&#039;s in that tblUsers????<BR><BR>The *LAST* thing you want to do is one query per user!<BR><BR>Go back and rethink this from the start!<BR><BR>Get *all* the (relevant) users in ONE query and then use all those wonderful .NET controls to do the looping. (DataRepeater springs to mind, but I&#039;m not sure what you want to do.)<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