can anyone please tell the code for pk constraint of id with a sql database in vb prgm?
i have written the code as"
code(vb):
rs1.Open "select * from empdetail", conn, adOpenStatic, adLockOptimistic
rs1.MoveFirst
While Not rs1.EOF
If rs1!id = txtid.Text Then
MsgBox ("Duplicate Entry")
Exit Sub
Else
txtname.SetFocus
conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
addcol
End If
Wend
rs.close
set rs = nothing
end sub
ERROR:operation cannot be done qwhen object ids open
THANKS IN ADVANCE
1 1329
Hi,
To Check for PK, open a Specific Record..
Not Necessary to Open Whole Table, and Loop.. -
-
rs1.Open "select * from empdetail Where ID='" & Trim(txtID.Text) & "'", conn, adOpenStatic, adLockOptimistic
-
IF RS1.EOF Then
-
conn.Execute "insert into empdetail(id,name,whours,rate,otrate) values ('" & txtid & "','" & txtname & "','" & txtwhr & "','" & txtrate & "','" & txtorate & "')"
-
MsgBox "INSERTED NEW RECORDS", vbOKOnly, "ADDING NEW RECORDS"
-
Else
-
' ID Found In DB (Duplicate)
-
MsgBox "Duplicate Entry"
-
End If
-
-
RS1.Close
-
Set RS1 = Nothing
-
Regards
Veena
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Simmons |
last post by:
How is it that even though I have the column "username" in my database set
as a Primary key, using my PHP script to add new users to the database works
without any errors even when signing up using...
|
by: Philip Yale |
last post by:
I'm probably going to get shot down with thousands of reasons for
this, but I've never really heard or read a convincing explanation, so
here goes ...
Clustered indexes are more efficient at...
|
by: 101 |
last post by:
Taking a course on SQL. They are saying you can get better performance by
having multiple files for a group.
They then graphically show an example of "Primary" with multiple data files.
I have...
|
by: serge |
last post by:
I ran into a table that is used a lot. Well less than
100,000 records. Maybe not a lot of records but i believe
this table is used often. The table has 26 fields, 9 indexes
but no Primary Key at...
|
by: bwmiller16 |
last post by:
Folks -
Linux RH3, UDB 8.2 FP9.
I've got two tiny test boxes that I'm setting up to get a simple HADR
configuration built. When I start the primary I get the famous SQL1768
RC=7 and also...
|
by: Geoff Cayzer |
last post by:
At http://www.blueclaw-db.com/tips_tricks.htm I came across a section
which is included below and was hoping for some comment on the
article.
--------------
Almost never use this auto-number...
|
by: Geoff Jones |
last post by:
Hi
Can anybody help me with the following problem? I have a datasource i.e.
some data, which I'm accessing via some VB. This I have done; with the help
of you guys. However, the original data,...
|
by: shumaker |
last post by:
I'm wondering if adding an autonumber primary key will improve the
performance of a multiuser access database on a network share. I have
a website that lists many tips for improving performance of...
|
by: Challenge |
last post by:
Hi,
I got error, SQL1768N Unable to start HADR. Reason code = "7", when I
tried to start hadr primary database. Here are the hadr configuration
of my primary db:
HADR database role ...
|
by: Danny |
last post by:
Hello,
We imported a bunch of tables from a database and realized that the
primary keys weren't copied to the destination db. In order to re-
create the keys, we need to know which tables have...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| |