TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
prince shils
NA
4
3.5k
Insert data into Foreign Key Table.
May 19 2012 11:45 PM
Hello Friends,
I want to insert data into foreign key Table with reference to the last entered primary key.
here is my code:
cmd.CommandText = string.Format("INSERT INTO Guest([FirstName],[LastName],[Adults],[Childs],[PhoneNo]) values(@fname,@lname,@Adults,@Childs,@PhNo) where [ReservationNo]==(Select @@IDENTITY From [Reservation])");
cmd.Parameters.Add("@fname", OleDbType.VarChar).Value = textBox1.Text;
cmd.Parameters.Add("@lname", OleDbType.VarChar).Value = textBox2.Text;
cmd.Parameters.Add("@Adults", OleDbType.Numeric).Value = textBox3.Text;
cmd.Parameters.Add("@Childs", OleDbType.Numeric).Value = textBox4.Text;
cmd.Parameters.Add("@PhNo", OleDbType.VarChar).Value = textBox5.Text;
cmd.ExecuteNonQuery();
MessageBox.Show("Data Insert!!");
con.Close();
Here is an error:
Syntax error (missing operator) in query expression '[ReservationNo]==(Select @@IDENTITY From [Reservation])'.
Note: I am using VS10, MSACCESS, C#
Reply
Answers (
1
)
String to byte
Object, Difference between a struct and a class