Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all...

How to make an INSERT INTO command in Database.ExecuteSqlCommand in LINQ VB.NET?
I'm getting error/exception like this:

{"An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name."}

Here's my actual code:

VB
db.Database.Connection.ConnectionString = EFManager.GetConnectionString
           db.Database.CommandTimeout = DomainConstant.MaximumTimeOut

           Dim ProjectID = model.ProjectID, Name = model.Name, FileAttachment = model.FileAttachment, FileSize = model.FileSize, CreatedBy = model.CreatedBy

           db.Database.ExecuteSqlCommand(
                 String.Format(" INSERT INTO [ProjectAttachment] " +
                                 " (ProjectID, Name, FileAttachment, FileSize, CreatedBy) " +
                                 " SELECT {0},{1},{2},{3},{4} " _
                                 , ProjectID, Name, FileAttachment, FileSize, CreatedBy))

       End Using


I hope someone could help me on this..

Thank you in advance...
Posted

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