SirReadAlot
asked on
Unclosed quotation mark before the character string
Hi experts,
Can you see this
Error:Line 1: Incorrect syntax near ')'. Unclosed quotation mark before the character string ')'.
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1\" ')";
I have closed everything!!
Can you see this
Error:Line 1: Incorrect syntax near ')'. Unclosed quotation mark before the character string ')'.
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
I have closed everything!!
ASKER
will do
i used 2 single quoted, you used double quoted.
In sql text is represented with single quotes, by using double quotes you were breaking the c# code and the code was expecting a variable
In sql text is represented with single quotes, by using double quotes you were breaking the c# code and the code was expecting a variable
ASKER
same error still
Label1.Text "Error:Line 1: Incorrect syntax near ')'.\r\nUnclosed quotation mark before the character string ')'." string
Label1.Text "Error:Line 1: Incorrect syntax near ')'.\r\nUnclosed quotation mark before the character string ')'." string
ASKER
did u do this on purpose
<wbr/>.
<wbr/>.
ah i see, its basically because the strin gis being broken, here:
', 'Extended <-- Where the comma is because of the quotes wither side, just trying to work out way around it
', 'Extended <-- Where the comma is because of the quotes wither side, just trying to work out way around it
ASKER
what about this
<wbr/>.
<wbr/>.
actually, should you not be specifying a source table/sheet and or username and password (which could be blank) in the OPENROWSET function:
from Books ONline:
...FROM OPENROWSET('Microsoft.Jet. OLEDB.4.0' , 'c:\MSOffice\Access\Sample s\northwin d.mdb'; 'admin'; 'mypwd', Orders)
from Books ONline:
...FROM OPENROWSET('Microsoft.Jet.
>>>what about this
sorry, i am using quick post and it puts them in sometimes - just ignore it, sorry
sorry, i am using quick post and it puts them in sometimes - just ignore it, sorry
Open it in the browser and it wont be there :o)
ASKER
i am using internet exploper
ASKER
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=\''Excel 8.0;HDR=Yes;IMEX=1\'','SEL ECT * FROM [Sheet1$] ' )";
does this work? If not try simply specifying the sheet name
ASKER
it doesnt work,
can u check to see if i got the quotation right?
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=\''Excel 8.0;HDR=Yes;IMEX=1\'','SEL ECT * FROM [Sheet1$] ' )";
thanks
can u check to see if i got the quotation right?
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
thanks
ASKER
the name of the spread sheet is sheet1
ASKER
ASKER
with this
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=\''Excel 8.0;HDR=Yes;IMEX=1\'','SEL ECT * FROM [Sheet1$] ' )";
i get incorrect syntax the KEYWORD SELECT
'SELECT * FROM [Sheet1$] ' )";
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
i get incorrect syntax the KEYWORD SELECT
'SELECT * FROM [Sheet1$] ' )";
thats because the string is broken again:
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB<wbr/> .4.0', 'Extended Properties=\''Excel 8.0;HDR=Yes;IMEX=1\'' ','SELECT * FROM [Sheet1$] ' )";
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
>>sorry, posted the <wbr/> again:
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=\''Excel 8.0;HDR=Yes;IMEX=1\'' ','SELECT * FROM [Sheet1$] ' )";
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
ASKER
wil try again thanks
ASKER
i have tried that, it seems to be geting better, it say
+ Label1 {Text=@"Error:Line 1: Incorrect syntax near '\'."} System.Web.UI.WebControls. Label
+ Label1 {Text=@"Error:Line 1: Incorrect syntax near '\'."} System.Web.UI.WebControls.
ASKER
i don't see what is incorrect
ASKER
am just gonna move the qoutes around
ASKER
no luck
ok, remove the / from the string, they are no longer necessary as you ar enot using double quotes:
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ','SELECT * FROM [Sheet1$] ' )";
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
ASKER
will try it
ASKER
Ex.Message "Line 1: Incorrect syntax near '\\'.\r\nUnclosed quotation mark before the character string ')'." string
wow!!! this is just typical
wow!!! this is just typical
ASKER
everything is closed
ASKER
void FromExcel(string strg)
{
con.Close();
con.Open();
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=' 'Excel 8.0;HDR=Yes;IMEX=1')";
// string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv er={Micros oft Excel Driver (*.xls)};DBQ=";
strr += parseSQL(strg);
strr += "','SELECT * FROM [Sheet1$]')";
SqlCommand SqlCmd= new SqlCommand(strr,con);
SqlCmd.ExecuteNonQuery();
//Importing the generic Excel file in to Master SQL Database
con.Close();
}
i have even made some adjustments but same error
{
con.Close();
con.Open();
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
// string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv
strr += parseSQL(strg);
strr += "','SELECT * FROM [Sheet1$]')";
SqlCommand SqlCmd= new SqlCommand(strr,con);
SqlCmd.ExecuteNonQuery();
//Importing the generic Excel file in to Master SQL Database
con.Close();
}
i have even made some adjustments but same error
ASKER
which is
Label1.Text "Error:Line 1: Incorrect syntax near 'Excel 8.0;HDR=Yes;IMEX=1'.\r\nUn
"select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro soft.Jet.O LEDB.4.0', 'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ','SELECT * FROM [Sheet1$] ' )";
the above works for me...
what if you run it in query analyser?
the above works for me...
what if you run it in query analyser?
ASKER
will c
copy and paste the above EXACTLY
when you have '' they need to be together, this represents a single quote in sql, this ' ' means nothing! they need to be side by side ''
when you have '' they need to be together, this represents a single quote in sql, this ' ' means nothing! they need to be side by side ''
ASKER
sorry, how did u test it in query analyser?
ASKER
this works
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv er={Micros oft Excel Driver (*.xls)};DBQ=";
but I just want to add 'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1''
so that i can import any data format
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv
but I just want to add 'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1''
so that i can import any data format
if you add it in:
this wont work:
'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1''
you need to close the quote at the end:
'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' <--
this wont work:
'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1''
you need to close the quote at the end:
'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' <--
ASKER
will try
ASKER
this is what I am currently trying
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte nded Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' ,'Driver={Microsoft Excel Driver (*.xls)};DBQ=";
will let you know
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte
will let you know
ASKER
sorry,
this is the error
{Text="Error:Line 1: Incorrect syntax near ','."}
this is the error
{Text="Error:Line 1: Incorrect syntax near ','."}
ok, let me just take a moment to expain
In C# when you want to represent a string you use double quotes:
" something "
in sql you need to use single quotes ', if you want to pass a single quote within an sql string you would do this by using 2 single quotes 'my mother''s maiden name is...'
in the above string you are not closing your SQL string properly:
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte nded Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' ,'Driver={Microsoft Excel Driver (*.xls)};DBQ="; <-- THERE SHOULD BE ' HERE
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte nded Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' ,'Driver={Microsoft Excel Driver (*.xls)};DBQ=' "; LIKE THIS
now... what do you need to append to the string?
lets forget the quotes and double quotes, remove them and post how it is that the WHOLE string should look like, as if you wee typing it into sql manually...
In C# when you want to represent a string you use double quotes:
" something "
in sql you need to use single quotes ', if you want to pass a single quote within an sql string you would do this by using 2 single quotes 'my mother''s maiden name is...'
in the above string you are not closing your SQL string properly:
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte
now... what do you need to append to the string?
lets forget the quotes and double quotes, remove them and post how it is that the WHOLE string should look like, as if you wee typing it into sql manually...
ASKER
Hi
i don't want to append any thing to the string.
I am trying to insert what ever data type is in my excel to the database, right now it works with this code
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv er={Micros oft Excel Driver (*.xls)};DBQ=";
but there are other datatype in the excel so i have to use imex
void FromExcel(string strg)
{
con.Close();
con.Open();
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte nded Properties=''Excel 8.0;HDR=Yes;IMEX=1'' ' ,'Driver={Microsoft Excel Driver (*.xls)};DBQ=' ";
// string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv er={Micros oft Excel Driver (*.xls)};DBQ=";
strr += parseSQL(strg);
strr += "','SELECT * FROM [Sheet1$]')";
SqlCommand SqlCmd= new SqlCommand(strr,con);
SqlCmd.ExecuteNonQuery();
//Importing the generic Excel file in to Master SQL Database
con.Close();
}
i don't want to append any thing to the string.
I am trying to insert what ever data type is in my excel to the database, right now it works with this code
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv
but there are other datatype in the excel so i have to use imex
void FromExcel(string strg)
{
con.Close();
con.Open();
string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Exte
// string strr ="SELECT * INTO ADC11.dbo.test1 FROM OPENROWSET('MSDASQL','Driv
strr += parseSQL(strg);
strr += "','SELECT * FROM [Sheet1$]')";
SqlCommand SqlCmd= new SqlCommand(strr,con);
SqlCmd.ExecuteNonQuery();
//Importing the generic Excel file in to Master SQL Database
con.Close();
}
>>but I just want to add 'Extended Properties=''Excel 8.0;HDR=Yes;IMEX=1''
i thought you said you needed to add something on:
ok, so what line is it erroring on, is it still this one:
{Text="Error:Line 1: Incorrect syntax near ','."}
i thought you said you needed to add something on:
ok, so what line is it erroring on, is it still this one:
{Text="Error:Line 1: Incorrect syntax near ','."}
ASKER
okay
lets forget the quotes and double quotes, remove them and post how it is that the WHOLE string should look like, as if you wee typing it into sql manually...
SELECT * INTO db1.dbo.table1 FROM OPENROWSET(MSDASQL,Driver= {Microsoft Excel Driver (*.xls)};DBQ=, SELECT * FROM [sheet1$])
lets forget the quotes and double quotes, remove them and post how it is that the WHOLE string should look like, as if you wee typing it into sql manually...
SELECT * INTO db1.dbo.table1 FROM OPENROWSET(MSDASQL,Driver=
ASKER
hold on apresto
ASKER
lets forget the quotes and double quotes, remove them and post how it is that the WHOLE string should look like, as if you wee typing it into sql manually...
SELECT * INTO db1.dbo.table1 FROM OPENROWSET(MSDASQL, Extended Properties= Excel 8.0;HDR=Yes;IMEX=1, Driver={Microsoft Excel Driver (*.xls)};DBQ=, SELECT * FROM [sheet1$])
string strr = "SELECT * INTO db1.dbo.table1 FROM OPENROWSET('MSDASQL','Driv er={Micros oft Excel Driver (*.xls)};DBQ=', [sheet1$])"
ok, does this work, i know its hasnt got a select at the end but try it out:
http://www.codecomments.com/archive352-2005-9-626923.html
ok, does this work, i know its hasnt got a select at the end but try it out:
http://www.codecomments.com/archive352-2005-9-626923.html
sorry, didnt refresh, ignore that comment
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
will try
ASKER
same error
Error:Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character string ')'.
Error:Line 1: Incorrect syntax near ','. Unclosed quotation mark before the character string ')'.
ASKER
with this code
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
i got this, looks good, its a diff error!!!!!!!
Error:Could not locate registry entry for OLE DB provider 'Provider=Microsoft.Jet.OL
hhuummm....not sure.
atleast we got past the old one - you might not have the driver installed. I'll try and find out what the error means and how to fix it
atleast we got past the old one - you might not have the driver installed. I'll try and find out what the error means and how to fix it
ASKER
me too, i shall search
try this:
string strr = "select * into ADC11.dbo.test1 FROM OPENROWSET('Provider=Micro
Apresto