Click here to Skip to main content
15,877,914 members

Comments by SomeGuyThatIsMe (Top 12 by date)

SomeGuyThatIsMe 10-Jul-14 8:42am View    
If you call thread.Sleep on a form it will usually lock the entire UI and make your app unresponsive until its done sleeping. Are you sure you dont want to use form.Hide or something to just make it go away until the user wants it again?
SomeGuyThatIsMe 15-Nov-13 15:07pm View    
I dont think you can insert a value into an identity column, you might have to change it to an integer. since the sp getnextId is replicating the functionality of an identity column. Its also possible that the sql i posted has a typo or two in it since i modified it in this reply box.
SomeGuyThatIsMe 15-Nov-13 13:28pm View    
CREATE PROCEDURE [dbo].[aspnet_AddGenealogy]
@FamilyName char(200),
@MiddleName1 char(200),
@MiddleName2 char(200),
@MiddleName3 char(200),
@FirstName char(200),
@DOB Nvarchar(100),
@Gender char(20),
@COOB char(200),
@SOB char(200),
@COB char(200),
@Newsletter Nvarchar(10),
@DateTimeGenealogy DateTime

AS
Begin
@nextId = usp_getNextId

INSERT INTO aspnet_Genealogy(GenealogyId,FamilyName, MiddleName1, MiddleName2, MiddleName3, FirstName, DOB, Gender, COOB, SOB, COB, Newsletter, DateTimeGenealogy) VALUES(@nextId, @FamilyName, @MiddleName1, @MiddleName2, @MiddleName3, @FirstName, @DOB, @Gender, @COOB, @SOB, @COB, @Newsletter, @DateTimeGenealogy)
--possibly do not need?
SELECT *
FROM aspnet_Users INNER JOIN aspnet_PersonalTree ON
aspnet_Users.UserId = aspnet_PersonalTree.UserId
INNER JOIN aspnet_Genealogy ON aspnet_PersonalTree.Id = aspnet_Genealogy.Id;

insert into aspnet_PersonalTree(GenealogyId, UserId) values(@nextid, @UserId)


END

I've modified your proc some, this text box is rather small so sorry if i added some typo's or missed something. I added the GenealogyId column to your first insert and the @nextId to be inserted as its value which is then used for the insert into personalTree with the userId. The catch is that you'll have to change genealogy to not use an identity column and create the getNextId procedure and a table to hold the values it deals with. The concept is basicly implementing your own version of an Identity column using a SP and table rather than the build in db functionality. Unless there is a way to get/reserve the next Id for the table so you can use it in multiple inserts.
SomeGuyThatIsMe 15-Nov-13 13:01pm View    
you dont assign @genealogyId anywhere, your select will also fail beacuse there is no link via the personalTree table yet. You need a way to get the genealogy id you just added for your insert w/out using a max. I never use ID columns i use a counter table and a sp to get the next value for whatever incremental id I want. that way i can call the SP and assign its return val to a varible in my main procedure and use it as many times as i want. i.e.

@nextId = usp_getNextId
insert into table(id..) values(@nextid...)

insert into joinTable(id, otherid) values(@nextId, @otherId)

hope that makes sense.
SomeGuyThatIsMe 15-Nov-13 12:06pm View    
beacuse your last insert is incomplete, it has no values clause or select statement after it.