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
-Andre Sam
NA
5
530
Error while submitting the query
Feb 3 2019 3:20 AM
Sorry, I am a beginner and it may be very basic question.
I have tested the below query and it does create a table and add all the contents from an excel file
SELECT *
INTO TEST_TABLE
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0; Database=D:\Vpath.xlsx; HDR=YES; IMEX=1',
'SELECT * FROM [Sheet1$]')
GO
I tried to do the same in visual studio with the below
string str = @"D:\path.xlsx";
string Str1 = "SELECT * INTO TEST_TABLE FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0','Excel 12.0; Database=" + str + "; HDR = YES; IMEX = 1',' SELECT * FROM [Sheet1$]'";
SqlConnection con = new SqlConnection("Connection...details");
con.Open();
SqlCommand cmd = new SqlCommand(Str1, con);
SqlDataReader reader = cmd.ExecuteReader();
cmd.ExecuteNonQuery();
reader.Close();
con.Close();
I get the below error
System.Data.SqlClient.SqlException: 'Incorrect syntax near ' SELECT * FROM [Sheet1$]'.'
Reply
Answers (
1
)
Xamarin Form consuming asmx web service
mfc120.dll is missing after opening my project exe