Showing posts with label embedded. Show all posts
Showing posts with label embedded. Show all posts

Tuesday, March 27, 2012

EXEC SQL CONNECT TO

We tried to use the embedded “EXEC SQL CONNECT TO servername.dbname USER u
name.password” but we kept getting the error message: “Server: Msg 156,
Level 15, State 1, Line 1
Incorrect syntax near the keyword 'TO'.”
We tried the upper / lower case of the “connect to”, with / without the
" around the server name, database name, user name, but none of them work. W
hat did we do wrong?
Thanks in advance for your help.This does not in any way seem to be valid SQL Server SQL language construct.
.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> We tried to use the embedded "EXEC SQL CONNECT TO servername.dbname USER uname.pas
sword" but we
kept getting the error message: "Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'TO'."
> We tried the upper / lower case of the "connect to", with / without the " around t
he server name,
database name, user name, but none of them work. What did we do wrong?
> Thanks in advance for your help.
>|||This is how it documented in the BOL or the URL below:
connect to:
_01_1g1b.asp" target="_blank">http://msdn.microsoft.com/library/d...>
_01_1g1b.asp
set connection:
_01_5pda.asp" target="_blank">http://msdn.microsoft.com/library/d...>
_01_5pda.asp
"Tibor Karaszi" wrote:

> This does not in any way seem to be valid SQL Server SQL language construc
t...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
> news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> kept getting the error message: "Server: Msg 156, Level 15, State 1, Line
1
> database name, user name, but none of them work. What did we do wrong?
>
>|||I see, this is embedded SQL, supposed to be run through a precompiler. I sup
pose that you have below
inside some C-program and you get the error message when you run the c-progr
am through the
precompiler? Is that the case?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:AB147E8A-3A19-4BDD-9B6C-D47F02C1C020@.microsoft.com...[vbcol=seagreen]
> This is how it documented in the BOL or the URL below:
> connect to:
> rf_01_1g1b.asp" target="_blank">http://msdn.microsoft.com/library/d...
rf_01_1g1b.asp
> set connection:
> rf_01_5pda.asp" target="_blank">http://msdn.microsoft.com/library/d...
rf_01_5pda.asp
>
>
> "Tibor Karaszi" wrote:
>
we[vbcol=seagreen]
name,[vbcol=seagreen]sql

EXEC SQL CONNECT TO

We tried to use the embedded â'EXEC SQL CONNECT TO servername.dbname USER uname.passwordâ' but we kept getting the error message: â'Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'TO'.â'
We tried the upper / lower case of the â'connect toâ', with / without the " around the server name, database name, user name, but none of them work. What did we do wrong?
Thanks in advance for your help.This does not in any way seem to be valid SQL Server SQL language construct...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> We tried to use the embedded "EXEC SQL CONNECT TO servername.dbname USER uname.password" but we
kept getting the error message: "Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'TO'."
> We tried the upper / lower case of the "connect to", with / without the " around the server name,
database name, user name, but none of them work. What did we do wrong?
> Thanks in advance for your help.
>|||I see, this is embedded SQL, supposed to be run through a precompiler. I suppose that you have below
inside some C-program and you get the error message when you run the c-program through the
precompiler? Is that the case?
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:AB147E8A-3A19-4BDD-9B6C-D47F02C1C020@.microsoft.com...
> This is how it documented in the BOL or the URL below:
> connect to:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/esqlforc/ec_6_erf_01_1g1b.asp
> set connection:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/esqlforc/ec_6_erf_01_5pda.asp
>
>
> "Tibor Karaszi" wrote:
> > This does not in any way seem to be valid SQL Server SQL language construct...
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
> > news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> > > We tried to use the embedded "EXEC SQL CONNECT TO servername.dbname USER uname.password" but
we
> > kept getting the error message: "Server: Msg 156, Level 15, State 1, Line 1
> > > Incorrect syntax near the keyword 'TO'."
> > >
> > > We tried the upper / lower case of the "connect to", with / without the " around the server
name,
> > database name, user name, but none of them work. What did we do wrong?
> > >
> > > Thanks in advance for your help.
> > >
> >
> >
> >

EXEC SQL CONNECT TO

We tried to use the embedded “EXEC SQL CONNECT TO servername.dbname USER uname.password” but we kept getting the error message: “Server: Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'TO'.”
We tried the upper / lower case of the “connect to”, with / without the " around the server name, database name, user name, but none of them work. What did we do wrong?
Thanks in advance for your help.
This does not in any way seem to be valid SQL Server SQL language construct...
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> We tried to use the embedded "EXEC SQL CONNECT TO servername.dbname USER uname.password" but we
kept getting the error message: "Server: Msg 156, Level 15, State 1, Line 1
> Incorrect syntax near the keyword 'TO'."
> We tried the upper / lower case of the "connect to", with / without the " around the server name,
database name, user name, but none of them work. What did we do wrong?
> Thanks in advance for your help.
>
|||This is how it documented in the BOL or the URL below:
connect to:
http://msdn.microsoft.com/library/de...rf_01_1g1b.asp
set connection:
http://msdn.microsoft.com/library/de...rf_01_5pda.asp
"Tibor Karaszi" wrote:

> This does not in any way seem to be valid SQL Server SQL language construct...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
> news:532A0CB3-51DC-46FE-AD74-E3FA921B3471@.microsoft.com...
> kept getting the error message: "Server: Msg 156, Level 15, State 1, Line 1
> database name, user name, but none of them work. What did we do wrong?
>
>
|||I see, this is embedded SQL, supposed to be run through a precompiler. I suppose that you have below
inside some C-program and you get the error message when you run the c-program through the
precompiler? Is that the case?
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"RC5640808" <RC5640808@.discussions.microsoft.com> wrote in message
news:AB147E8A-3A19-4BDD-9B6C-D47F02C1C020@.microsoft.com...[vbcol=seagreen]
> This is how it documented in the BOL or the URL below:
> connect to:
> http://msdn.microsoft.com/library/de...rf_01_1g1b.asp
> set connection:
> http://msdn.microsoft.com/library/de...rf_01_5pda.asp
>
>
> "Tibor Karaszi" wrote:
we[vbcol=seagreen]
name,[vbcol=seagreen]

Wednesday, March 7, 2012

Exception thrown: database file cannot be found

Hi,

I'm developing a desktop C# app that uses SQL Everywhere as an embedded database.
I generated strongly typed DataSet and use that to populate a DataGrid on my app.

When the app first loads, it populates the DataGrid with a line like this:

this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);

That all works fine. Later on, after adding more data to the database (through reading a csv file), I wanted to refresh the display on the DataGrid.

I used the same line of code:

this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);

however, this time, the following exception was thrown:

The database file cannot be found. Check the path to the database. [ File name = .\\Inventories.sdf ]

Does anyone know what may be going on? I saw this article about a bug in VS 2005 when using strongly typed DataSets (http://channel9.msdn.com/wiki/default.aspx/MobileDeveloper.DatabaseCannotBeFoundErrorInTypedDataset)
but that doesn't seem to apply here.

The connection string is identical both times that line of code is called so I'm a bit baffled with what's going on.

Any help would be appreciated. Thanks,

Jose

Windows CE does not support relative paths you're trying to use. You must specify correct absolute path to the database located on device file system.

Also keep in mind Windows CE does not have drive letters and can't see your desktop's C: (D:, etc) drive as many developers seem to believe.

|||I'm not running this on Windows CE. I'm trying out the new SQL Server Everywhere and using it on Windows XP.

Thanks though.|||

If file can not be found that's probably because it can't be found. You can use File.Exists() to verify that.

|||Thanks for the input!!

It sounds so simple and yet I hadn't thought about that. I kept looking for the complicated answer.

It turns out, my database file was there all along. The problem was, after opening and reading the CSV files to import into the db, the next time I tried to access the db the app was looking for the db file in the same directory where my CSVs where...and of course, it wasn't finding it.

So now, after reading a CSV and prior to re-querying the db, I use Directory.SetCurrentDirectory() to reset where the app looks for its db.

Thanks for the help, I had been stumped by this for a week.

-Jose|||

this one has had me scratching my head for a day so I'm glad I haven't spent a week...

I'm using a separate project as a class library with a *.sdf database so it can be re-used for several projects.

I had the exact problem, everything was good until I opened OpenFileDialog(), then things went south after that.

Just a note to your solution... (maybe you do this already)...but you can assign the OpenFileDialog.RestoreDirectory flag to true and then after it closes the original directory will be restored prior to the open dialog....that way you don't need the Directory.SetCurrentDirectory.

fileChooser = new OpenFileDialog();

fileChooser.RestoreDirectory = true;

gl

Exception thrown: database file cannot be found

Hi,

I'm developing a desktop C# app that uses SQL Everywhere as an embedded database.
I generated strongly typed DataSet and use that to populate a DataGrid on my app.

When the app first loads, it populates the DataGrid with a line like this:

this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);

That all works fine. Later on, after adding more data to the database (through reading a csv file), I wanted to refresh the display on the DataGrid.

I used the same line of code:

this.sTORE_INV_LNTableAdapter.Fill(this.inventoriesDataSet.STORE_INV_LN);

however, this time, the following exception was thrown:

The database file cannot be found. Check the path to the database. [ File name = .\\Inventories.sdf ]

Does anyone know what may be going on? I saw this article about a bug in VS 2005 when using strongly typed DataSets (http://channel9.msdn.com/wiki/default.aspx/MobileDeveloper.DatabaseCannotBeFoundErrorInTypedDataset)
but that doesn't seem to apply here.

The connection string is identical both times that line of code is called so I'm a bit baffled with what's going on.

Any help would be appreciated. Thanks,

Jose

Windows CE does not support relative paths you're trying to use. You must specify correct absolute path to the database located on device file system.

Also keep in mind Windows CE does not have drive letters and can't see your desktop's C: (D:, etc) drive as many developers seem to believe.

|||I'm not running this on Windows CE. I'm trying out the new SQL Server Everywhere and using it on Windows XP.

Thanks though.

|||

If file can not be found that's probably because it can't be found. You can use File.Exists() to verify that.

|||Thanks for the input!!

It sounds so simple and yet I hadn't thought about that. I kept looking for the complicated answer.

It turns out, my database file was there all along. The problem was, after opening and reading the CSV files to import into the db, the next time I tried to access the db the app was looking for the db file in the same directory where my CSVs where...and of course, it wasn't finding it.

So now, after reading a CSV and prior to re-querying the db, I use Directory.SetCurrentDirectory() to reset where the app looks for its db.

Thanks for the help, I had been stumped by this for a week.

-Jose
|||

this one has had me scratching my head for a day so I'm glad I haven't spent a week...

I'm using a separate project as a class library with a *.sdf database so it can be re-used for several projects.

I had the exact problem, everything was good until I opened OpenFileDialog(), then things went south after that.

Just a note to your solution... (maybe you do this already)...but you can assign the OpenFileDialog.RestoreDirectory flag to true and then after it closes the original directory will be restored prior to the open dialog....that way you don't need the Directory.SetCurrentDirectory.

fileChooser = new OpenFileDialog();

fileChooser.RestoreDirectory = true;

gl