Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
OleDbCommand cmd = new OleDbCommand("INSERT INTO SlideShowTable1 ss(ss.ImageName,ss.Description,ss.CategoryName,ss.ADshop_name,ss.ADShop_Address,ss.ADshop_city,ss.ADShop_mob,ss.ADshop_Email,ss.U_id,ss.AreaName,ss.startddate,ss.endddate,ss.ImagePath,ss.BImageName,ss.BImagePath,ss.Total_Days,ss.Days_remain)Select u.U_id ,u.U_name, u.U_Email,s.ImageName ,s.Description,s.CategoryName,s.ADshop_name,s.ADShop_Address,s.ADshop_city,s.ADshop_mob,s.ADshop_Email,s.AreaName,s.startddate,s.endddate,s.ImagePath,s.BImageName,s.BImagePath,s.Total_Days,s.Days_remain from LOGIN u ,SlideShowTable s where u.U_id= " + userid, s.U_id = " + userid,ss.U_id=" + userid, con);

        int result = cmd.ExecuteNonQuery();

it gives an error that s is not exist in current contex
Posted
Updated 28-Apr-13 9:22am
v2
Comments
ExpertITM 28-Apr-13 14:03pm    
you can write query for inserting from select by,
insert into SlideShowTable1(column names)
select ..........

1 solution

Your problem is at the end of you OleDbCommand
u.U_id= " + userid, s.U_id = " + userid,ss.U_id=" + userid, con);

You need some extra quotation marks in there - I think it should be
u.U_id= " + userid + ", s.U_id = " + userid + ",ss.U_id=" + userid, con);

I suspect you'll then probably end up with a sql error but at least your code will compile
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900