Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to run an SQL-Script using OLEDB

51 views
Skip to first unread message

Jost Lindemann

unread,
Jul 26, 2010, 5:09:02 AM7/26/10
to
Hi,


I wrote a c#-program to manage a databasefile.

what i want to do :

Check if an certain table exists in my database-file (Access-DB).
If it does not exists, create a new table and insert 3 rows.

For this task, i wrote a sql-script which runs fine when started from

Running ExecuteNonQuery from my program failed, because only Update,Insert
and Delete is allowed.

How can i run this script using OLEDB ?

Thanks in advance !
Jost


Erland Sommarskog

unread,
Jul 26, 2010, 10:31:02 AM7/26/10
to
To start with, this is definitely not the correct newsgroup. This
newsgroup is about the native OLE DB interface itself, not the .Net
class.

Next, I think it sounds very strange. Not that I know Access, but there is
little reason why you should not be able to create a table through
ExecuteNonQuery. But I think you are better off asking in an Access
forum. Don't forget to include the exact text of the error message!


--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Kenneth A. Larsen

unread,
Jul 28, 2010, 9:01:56 PM7/28/10
to

"Jost Lindemann" <lindema...@t-online.de> wrote in message
news:i2jivs$c5o$03$1...@news.t-online.com...

You're welcome.
>
>

Kenneth A. Larsen

unread,
Jul 29, 2010, 2:22:30 PM7/29/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message
news:EA474CB8-17A5-4741...@microsoft.com...

Mary Chipman [MSFT]

unread,
Jul 30, 2010, 7:33:51 PM7/30/10
to
I'd recommend using a pre-existing table in the Access database rather
than trying to create one from scratch at run time. As you've found,
it's easy to execute DML statements from your C# code. Another issue
you may have is that by creating and dropping tables, your Access
database may become quite bloated, requiring frequent compact/repair
operations to avoid becoming corrupted.

--Mary

Kenneth A. Larsen

unread,
Jul 30, 2010, 8:10:05 PM7/30/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:434BC20A-26CE-41CD...@microsoft.com...

Kenneth A. Larsen

unread,
Jul 31, 2010, 9:01:09 PM7/31/10
to

"Mary Chipman [MSFT]" <mc...@online.microsoft.com> wrote in message
news:41o6565kc6arjtdld...@4ax.com...

You're welcome!
>>

Kenneth A. Larsen

unread,
Jul 31, 2010, 9:00:54 PM7/31/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:04F5259B-42E6-4EC7...@microsoft.com...

Kenneth A. Larsen

unread,
Aug 1, 2010, 11:43:39 AM8/1/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:1D0DDB48-FDDF-4B72...@microsoft.com...

Kenneth A. Larsen

unread,
Aug 3, 2010, 6:23:57 PM8/3/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:D6800157-6AF5-4EFD...@microsoft.com...

Kenneth A. Larsen

unread,
Aug 23, 2010, 10:01:32 PM8/23/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:E4927307-85AC-4D43...@microsoft.com...

Kenneth A. Larsen

unread,
Aug 30, 2010, 4:54:41 PM8/30/10
to

"Kenneth A. Larsen" <Lar...@verizon.net> wrote in message

news:8E19B5DD-BA51-4E2C...@microsoft.com...

0 new messages