Results 1 to 10 of 10

Thread: Is this a copy or original

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Location
    Smithfield, Utah
    Posts
    19

    Is this a copy or original

    Im working in VB with an ADODB connection to an ACCESS database. With a SAVE button click, I want to check to see if there is only "1" instance of the record to be saved and save it. If not, then I want to populate a DATAGRID with both instances so the user can select which one is the right one. SO, how can I check this without viewing the data first?

    Thanks

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Do you want to do this in VB.NET ?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Location
    Smithfield, Utah
    Posts
    19
    Yes. It's the only language I know right now.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Not sure what you mean by 1 instance of the record . And also , ADODB doesn't exist in VB.NET but you can use it interop which is no one recommend , instead use "ADO.NET" .

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Location
    Smithfield, Utah
    Posts
    19
    With "1" instance, I mean, I only want to have "1" file saved to the database, not many of the same name etc... ADODB is the reference, sorry.

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Dooglo
    With "1" instance, I mean, I only want to have "1" file saved to the database, not many of the same name etc... ADODB is the reference, sorry.
    So , basically you want to check if the record is already exist , then don't add otherwise , add it to the database ??

    I know ADODB , but I forgot how to use it (I used to use it in VB6 days ) . Do you know how to use ADO.NET ? Or do you know anything about it ?

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Location
    Smithfield, Utah
    Posts
    19
    Yes. Ok.

  8. #8
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Originally posted by Dooglo
    Yes. Ok.
    Well , I don't know what you mean by 'OK' but I assume you refer to 'ADO.NET' . Use this before you add any record . It returns true if data already exists , otherwise false .

    VB Code:
    1. Public Function Check_Existed(ByVal TablStr As String, ByVal ColumStr As String, ByVal ChkStr As String) As Boolean
    2.                 Dim sqlst As String = "SELECT * FROM " & TablStr & " WHERE " & ColumStr & "= " & " '" & ChkStr & "'"
    3.                 Dim mycom As New OleDbCommand(sqlst, MyConnection)
    4.  
    5. 'You should open the connection to your database .
    6. OpenDB()
    7.                 Dim reader As OleDbDataReader = mycom.ExecuteReader(CommandBehavior.CloseConnection)
    8.  
    9.                 If reader.Read() Then
    10.                     MessageBox.Show("Already existed")
    11.                     reader.Close()
    12.                     Return True
    13.                 Else
    14.                     reader.Close()
    15.                     Return False
    16.                 End If
    17.  
    18.                 reader = Nothing
    19.                 CloseDB.CloseDB()
    20.             End Function

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Feb 2004
    Location
    Smithfield, Utah
    Posts
    19
    Thanks.

    I'll try that and let you know.

  10. #10
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    Hi,

    "Im working in VB with an ADODB connection to an ACCESS database. With a SAVE button click, I want to check to see if there is only "1" instance of the record to be saved and save it. If not, then I want to populate a DATAGRID with both instances so the user can select which one is the right one. SO, how can I check this without viewing the data first?"

    I am wondering if you have been correctly understood.

    Are you saying that in your program it is possible to have the same new record to be added to a database, existing in more than one location and that they may have different field contents?
    So that you then require the user to select which record should be saved to the database? If so, how do you determine that it is the same record and not a different, but with similar content, one? Where will these multiple records be held?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

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



Click Here to Expand Forum to Full Width