|
-
Mar 9th, 2004, 11:38 PM
#1
Thread Starter
Junior Member
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
-
Mar 9th, 2004, 11:48 PM
#2
Sleep mode
Do you want to do this in VB.NET ?
-
Mar 9th, 2004, 11:52 PM
#3
Thread Starter
Junior Member
Yes. It's the only language I know right now.
-
Mar 9th, 2004, 11:57 PM
#4
Sleep mode
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" .
-
Mar 10th, 2004, 12:00 AM
#5
Thread Starter
Junior Member
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.
-
Mar 10th, 2004, 12:05 AM
#6
Sleep mode
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 ?
-
Mar 10th, 2004, 06:49 AM
#7
Thread Starter
Junior Member
-
Mar 10th, 2004, 07:03 AM
#8
Sleep mode
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:
Public Function Check_Existed(ByVal TablStr As String, ByVal ColumStr As String, ByVal ChkStr As String) As Boolean
Dim sqlst As String = "SELECT * FROM " & TablStr & " WHERE " & ColumStr & "= " & " '" & ChkStr & "'"
Dim mycom As New OleDbCommand(sqlst, MyConnection)
'You should open the connection to your database .
OpenDB()
Dim reader As OleDbDataReader = mycom.ExecuteReader(CommandBehavior.CloseConnection)
If reader.Read() Then
MessageBox.Show("Already existed")
reader.Close()
Return True
Else
reader.Close()
Return False
End If
reader = Nothing
CloseDB.CloseDB()
End Function
-
Mar 10th, 2004, 08:23 AM
#9
Thread Starter
Junior Member
Thanks.
I'll try that and let you know.
-
Mar 10th, 2004, 07:36 PM
#10
PowerPoster
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|