Solved

Need help with an insert statement

Posted on 2009-07-15
5
162 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
5 Comments
 
LVL 5

Expert Comment

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

Expert Comment

by:jinal
Comment Utility
You have to insert record or update record ?
0
 

Author Comment

by:VBBRett
Comment Utility
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 500 total points
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now