Click here to Skip to main content
15,894,460 members
Home / Discussions / Database
   

Database

 
AnswerRe: Alias for table names Pin
softty28-Aug-05 8:27
softty28-Aug-05 8:27 
Questiondynamic datasource on reporting services Pin
Ali Sapanci25-Aug-05 23:18
Ali Sapanci25-Aug-05 23:18 
AnswerRe: dynamic datasource on reporting services Pin
Ali Sapanci28-Aug-05 22:28
Ali Sapanci28-Aug-05 22:28 
Questionquerying a Acces DataBase Pin
Binary011025-Aug-05 21:26
Binary011025-Aug-05 21:26 
AnswerRe: querying a Acces DataBase Pin
beatles169227-Aug-05 2:22
beatles169227-Aug-05 2:22 
QuestionMore info on: Error Could Not Lock File Pin
Javolin25-Aug-05 12:28
Javolin25-Aug-05 12:28 
GeneralMDAC Sdk 2.8 Help Pin
dvptUml24-Aug-05 13:46
dvptUml24-Aug-05 13:46 
GeneralRecord locking ADO -net Pin
HahnTech24-Aug-05 9:47
HahnTech24-Aug-05 9:47 
Hello,
I have windows form application that is updating an sql2k db. Because we want serial keys we have decide to not use SQL2k to generate the keys. To facilitate this we have a table that holds the last key (lastkey) for each table. Right now for each insert into a table this key table must be hit and updated. So in code we have a

Select lastkey form tbKey into an ADO recordset
Update tbKey set lastkey = rs(0)+1

Now that has worked for 3 years. Yesterday it broke. Two applications selected lastkey at the same time and thus inserting the same PK into a table. That sucked what sucked more is that it was a published database so it took out all of the subscribers.

I’ve come up with this bit of sql to update and get the the key at the same time, within one record lock.
declare @Last_System_id int
update tbkey
set tbkey.lastkey =(lastkey+1), @Last_System_id = lastkey+1
where tbname='sometablename'
select @Last_System_id as myKey

I can’t figure out how to execute it with ADO and VB6. Actually it executes just fine. I can’t figure out how to get that select to return into a recordset.
I’ve tried this.

Dim sUpdate as string<br />
Dim NewKey as int <br />
sUpdate = "declare @Last_System_id int update tbkey set tbkey.lastkey =(lastkey+1), Last_System_id = lastkey+1 	where tbname='sometablename' select @Last_System_id as myKey"

<br />
Connection.open<br />
Set my_Recordset = Connection.Execute(sUpdate)<br />
NewKey = my_Recordset(0)

My_recordset is empty I also tried:
<br />
My_Recordset(1)<br />
My_Recordset("myKey")


All give me this error “Run-time error ‘3265’ Item cannot be found in the collection corresponding to the requested name or ordinal.”

Any insight will be much appreciated.
Thanks Ron



Ronald Hahn, CNT - Computer Engineering Technologist

New Technologies Analyst

HahnTech Affiliated With Code Constructors
Edmonton, Alberta, Canada
Email: rhahn82@telus.net
GeneralRe: Record locking ADO -net Pin
miah alom25-Aug-05 8:36
miah alom25-Aug-05 8:36 
GeneralRe: Record locking ADO -net Pin
HahnTech25-Aug-05 8:51
HahnTech25-Aug-05 8:51 
GeneralRe: Record locking ADO -net Pin
Rob Graham26-Aug-05 11:48
Rob Graham26-Aug-05 11:48 
GeneralRe: Record locking ADO -net Pin
Alomgir Miah28-Aug-05 7:39
Alomgir Miah28-Aug-05 7:39 
QuestionOpen Source Data Modeling Software? Pin
Turtle Hand24-Aug-05 7:34
Turtle Hand24-Aug-05 7:34 
QuestionInsert Null Value to Foxpro table? Pin
Member 185596324-Aug-05 5:58
Member 185596324-Aug-05 5:58 
AnswerRe: Insert Null Value to Foxpro table? Pin
Michael Potter25-Aug-05 9:55
Michael Potter25-Aug-05 9:55 
GeneralRe: Insert Null Value to Foxpro table? Pin
Member 185596325-Aug-05 22:30
Member 185596325-Aug-05 22:30 
GeneralRe: Insert Null Value to Foxpro table? Pin
Michael Potter26-Aug-05 3:43
Michael Potter26-Aug-05 3:43 
GeneralRe: Insert Null Value to Foxpro table? Pin
Member 185596326-Aug-05 3:54
Member 185596326-Aug-05 3:54 
Generalte data in just one columnBulk Insert from text File Pin
Daredeviljpr24-Aug-05 5:04
Daredeviljpr24-Aug-05 5:04 
GeneralRe: te data in just one columnBulk Insert from text File Pin
Frank Kerrigan24-Aug-05 6:03
Frank Kerrigan24-Aug-05 6:03 
GeneralRe: te data in just one columnBulk Insert from text File Pin
Daredeviljpr25-Aug-05 3:48
Daredeviljpr25-Aug-05 3:48 
GeneralStored Procedures or Direct SQL Statements Pin
emadns24-Aug-05 0:23
emadns24-Aug-05 0:23 
GeneralRe: Stored Procedures or Direct SQL Statements Pin
Frank Kerrigan24-Aug-05 0:35
Frank Kerrigan24-Aug-05 0:35 
GeneralRe: Stored Procedures or Direct SQL Statements Pin
Colin Angus Mackay24-Aug-05 1:30
Colin Angus Mackay24-Aug-05 1:30 
GeneralRe: Stored Procedures or Direct SQL Statements Pin
Yulianto.25-Aug-05 0:52
Yulianto.25-Aug-05 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.