Showing posts with label possibility. Show all posts
Showing posts with label possibility. Show all posts

Sunday, March 11, 2012

Creating a new database programmatically

I've seen several post asking for that possibility, but all 've read, didn't help me.

Some sing SQLDMO, other suggest to use SQLSMO, others only explaining to connect to a server and then do "CREATE DATABASE".

I will do this within .Net. Connecting to a SQL Server 2005 and execute "CREATE DATABASE" I could realize.
But how doing this with SQLExpress? Trying to do SqlConnection.Open with a non existing DB does not work., says "file not exists".
Or do I only have the wrong connection string? Can someone post here an excample connection string, which works with a non existing database?

Some hints I've read make me considering to use SQLSMO. But I don't have it on my computer. Where do I get it from? Any links would be nice.

You are right you can do it with DMO(data management object) and SMO(sql server management objects) but it is better to use ADO.NET ExecuteNoneQuery to create the database and objects. Try the link below for code sample. Hope this helps.

http://www.c-sharpcorner.com/Code/2002/Mar/CreatingDBProgrammaticallyMCB.asp

|||

Sorry thats was for Windows Form try the link below for code from Microsoft.

http://support.microsoft.com/default.aspx?scid=kb;en-us;305079

|||

Txh,

I've tried a similar excample and it did work for SQLServer. With SQLExpress I get an error, when opening the connection, something like "File not found".

What is the connection string for the SQLExpress? I replaces simple "Server=(local)" with "Server=.\\SQLEXPESS".

|||That code was talking about your server name, and the Master database that installs with every SQL Server. You are connecting to the Master database and file not found is not a valid error because the Master is always there. So try changing Express to your computer name. Hope this helps,|||

Sorry, if my english is so bad.

I wrote, that I've tried this excample, slightly changed and that it did work for SQL Server, but not SQLExpress.
Changing the server name to ".\SQLEXPRESS" didn't help. May be, because SQLExpress has no master database.

So, how to change this sample code that it works with SQLExpress?

|||

You cannot run SQL Server without the Master database, all your internal house keeping is done by the Master, I know I ran the Express in beta and it had a Master. And it must be your computer name and the Express for it to work YOUR_COMPUTER_NAME\SQLEXPRESS. Hope this helps.

Creating a MODEL

Is there any possibility to save a REPORT like a MODEL ? I mean for using the
same layout,fonts,etc..
--
TabacaruYes, you can save a report off to the side with basic layout and formatting
and use it as the starting point for creating additional reports.
--
Cheers,
'(' Jeff A. Stucker
\
Business Intelligence
www.criadvantage.com
---
"Tabacaru Teodor" <TabacaruTeodor@.discussions.microsoft.com> wrote in
message news:4B494061-035C-4E75-9280-CE3E09E98D46@.microsoft.com...
> Is there any possibility to save a REPORT like a MODEL ? I mean for using
> the
> same layout,fonts,etc..
> --
> Tabacaru|||And you can add it to the VS template directory to add it to the 'add new
item' list. Several articles have been published which demonstate this.
--
Brian Welcker
Group Program Manager
Microsoft SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jeff A. Stucker" <jeff@.mobilize.net> wrote in message
news:uYXEk4m%23EHA.3336@.TK2MSFTNGP11.phx.gbl...
> Yes, you can save a report off to the side with basic layout and
> formatting and use it as the starting point for creating additional
> reports.
> --
> Cheers,
> '(' Jeff A. Stucker
> \
> Business Intelligence
> www.criadvantage.com
> ---
> "Tabacaru Teodor" <TabacaruTeodor@.discussions.microsoft.com> wrote in
> message news:4B494061-035C-4E75-9280-CE3E09E98D46@.microsoft.com...
>> Is there any possibility to save a REPORT like a MODEL ? I mean for using
>> the
>> same layout,fonts,etc..
>> --
>> Tabacaru
>