1 Replies - 2111 Views - Last Post: 30 June 2012 - 06:01 AM Rate Topic: -----

#1 CharlieMay  Icon User is offline

  • This space intentionally left blank
  • member icon

Reputation: 1533
  • View blog
  • Posts: 4,919
  • Joined: 25-September 09

Create a Duplicate Dataset If Row.Count > 0

Posted 15 February 2012 - 10:00 AM

This one just happened today and I'm not yet sure that the OP understands is happening. Here is the code.
If e.KeyChar = Chr(13) Then
            Dim cnntemp As New OleDbConnection("provider = Microsoft.jet.oledb.4.0; data source=..\prms_database.mdb")
            Dim acctemp As String
            Dim da2temp As New OleDb.OleDbDataAdapter
            Dim objcommandtemp As New OleDb.OleDbCommand
            Dim ds2temp As New DataSet
            acctemp = "select * from prms_patient where pat_patno = '" & mtbPatNo.Text & "'"
            da2temp = New OleDb.OleDbDataAdapter(acctemp, cnntemp)
            da2temp.Fill(ds2temp, "temp")
            cnntemp.Close()
            If ds2temp.Tables("temp").Rows.Count = 0 Then

                MessageBox.Show("Invalid Patient or Family Number!", "Try Again", MessageBoxButtons.OK)
                Return
            Else

                Dim cnn2 As New OleDb.OleDbConnection("provider = Microsoft.jet.oledb.4.0; data source=..\prms_database.mdb")
                Dim acc As String
                Dim da2 As New OleDb.OleDbDataAdapter
                Dim objcommand As New OleDb.OleDbCommand
                Dim ds2 As New DataSet
                'Dim temp As String
                acc = "select * from prms_patient where pat_patno = '" & mtbPatNo.Text & "'"
                da2 = New OleDb.OleDbDataAdapter(acc, cnn2)
                da2.Fill(ds2, "temp")
                cnn2.Close()

                If ds2.Tables("temp").Rows.Count > 0 Then
                    tbFN.Text = ds2.Tables("temp").Rows(0).Item("pat_fn").ToString
                    cbMI.SelectedItem = ds2.Tables("temp").Rows(0).Item("pat_mi").ToString
                    tbSN.Text = ds2.Tables("temp").Rows(0).Item("pat_sn").ToString
                    tbAdd.Text = ds2.Tables("temp").Rows(0).Item("pat_add").ToString
                    If Trim(ds2.Tables("temp").Rows(0).Item("pat_gender").ToString) = "Male" Then
                        rbMale.Select()
                    Else
                        rbFemale.Select()
                    End If
                    cbStat.SelectedItem = ds2.Tables("temp").Rows(0).Item("pat_stat").ToString
                    mtbMobile.Text = ds2.Tables("temp").Rows(0).Item("pat_mobile").ToString
                    mtbLand.Text = ds2.Tables("temp").Rows(0).Item("pat_landline").ToString
                    pbox.ImageLocation = ds2.Tables("temp").Rows(0).Item("pat_pic").ToString
               End If
            End If
        End If


In other words, Fill a dataset based on a query result and...

If it returns 0 rows then
Notify the user that the ID was invalid.
Else 'So it returned more than 0 rows so now we know that query worked
'create all new Data Objects and perform the same query to fill yet another dataset

'then if the row count (once again) is above 0 then
'populate the textboxes.
...

This post has been edited by CharlieMay: 15 February 2012 - 10:01 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Create a Duplicate Dataset If Row.Count > 0

#2 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 525
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Create a Duplicate Dataset If Row.Count > 0

Posted 30 June 2012 - 06:01 AM

This is a very simple training issue. I bet your employee worked on paradox databases before.

Just set them straight and they will be able to code better for you in minutes flat.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1