Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Need help with an insert statement

Posted on 2009-07-15
5
Medium Priority
?
171 Views
Last Modified: 2012-05-07
I am in need of some help with an insert statement that I have in my asp.net application.  In my SQLDATA Source I have the following in my Insert area...Below is my code.  What I want to do is the following but it doesn't appear to work.  Does anybody have a clue as to how I can fix this?  Thanks!

Insert Into [dbo].MemberFamilyInfo (MemberFamilyNumber, Allergies, Weight, Age, DateOfBirth, MemberFamilyCreatedDate, MemberFamilyCreatedBy) VALUES (@MemberFamilyNumber, @Allergies, @Weight, @Age,@DateOfBirth, @MemberFamilyCreatedDate,  @MemberFamilyCreatedBy) Where EmployeeID = @EmployeeID
0
Comment
Question by:VBBRett
  • 2
4 Comments
 
LVL 5

Expert Comment

by:Aaronroach
ID: 24862115
Why do you have a where clause on you insert statement?
0
 
LVL 15

Expert Comment

by:jinal
ID: 24862235
You have to insert record or update record ?
0
 

Author Comment

by:VBBRett
ID: 24869537
Aaron, I am trying to insert a a statement with the EmployeeID being the value of the session object.  Is there a way I can do that?
0
 
LVL 15

Accepted Solution

by:
jinal earned 2000 total points
ID: 24869585
now use that insertstatement string in CommandText property.

/* C# */
 
string insertstatement = String.Format("Insert Into [dbo].MemberFamilyInfo (EmployeeID,MemberFamilyNumber, Allergies, Weight, Age, DateOfBirth, MemberFamilyCreatedDate, MemberFamilyCreatedBy) VALUES (@EmployeeID,@MemberFamilyNumber, @Allergies, @Weight, @Age,@DateOfBirth, @MemberFamilyCreatedDate,  @MemberFamilyCreatedBy)", Session["EmployeeID"].ToString());
 
/* VB.net */
 
Dim insertstatement  as String = String.Format("Insert Into [dbo].MemberFamilyInfo (EmployeeID,MemberFamilyNumber, Allergies, Weight, Age, DateOfBirth, MemberFamilyCreatedDate, MemberFamilyCreatedBy) VALUES (@EmployeeID,@MemberFamilyNumber, @Allergies, @Weight, @Age,@DateOfBirth, @MemberFamilyCreatedDate,  @MemberFamilyCreatedBy)", Session["EmployeeID"].ToString());

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question