Showing posts with label computer. Show all posts
Showing posts with label computer. Show all posts

Wednesday, March 21, 2012

Create SQL database with C#

Hi,

I am trying to:
1. Create a SQL database (I am working with SQL 2005 Express)
2. with a C# code
3. when the user is not the computer administrator.

I have managed to create the database file (code below). I am not sure
it is the right way.
Can you take a look please?
I would like to either create a password for these database or a
special user so only my
software will be able to control it (change data). How do I do that?

tmpConn.ConnectionString = "Data Source=(local); DATABASE =
master;Integrated Security=True; user instance=true";
sqlCreateDBQuery = " CREATE DATABASE " + DBParam.DatabaseName +
" ON
PRIMARY "
+ " (NAME = " +
DBParam.DataFileName +", "
+ " FILENAME = '" +
DBParam.DataPathName +"', "
+ " SIZE = 5MB,"
+ " FILEGROWTH =" +
DBParam.DataFileGrowth +") "
+ " LOG ON (NAME =" +
DBParam.LogFileName +", "
+ " FILENAME = '" +
DBParam.LogPathName + "', "
+ " SIZE = 1MB, "
+ " FILEGROWTH =" +
DBParam.LogFileGrowth +") ";
SqlCommand myCommand = new SqlCommand(sqlCreateDBQuery, tmpConn);
try
{
tmpConn.Open();
MessageBox.Show(sqlCreateDBQuery);
myCommand.ExecuteNonQuery();
MessageBox.Show("Database has been created successfully!",
"Create
Database", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.ToString(), "Create Database",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
finally
{
tmpConn.Close();
}orenbt78 (orenbt78@.googlemail.com) writes:

Quote:

Originally Posted by

I have managed to create the database file (code below). I am not sure
it is the right way.
Can you take a look please?


I guess that if the database gets created that it works. The only thing
to consider is maybe the initial sizes. 5 MB is a quite small database.
Then again, I don't really know what you will put into it.

Quote:

Originally Posted by

I would like to either create a password for these database or a
special user so only my
software will be able to control it (change data). How do I do that?


You could use an application role. You add users to the database without
any privileges, and then the application users sp_setapprole to set the
application role, to which you have granted all necessary rights.
To activate the application role, you need a password.

But note that this does not prevent users from side-stepping your tool,
it just makes it more difficult. If you give users the password, they
can use sp_setapprole from Mgmt Studio. If you don't give them the
password, you need to hide in the application, in which case be found
for anyone who wants. Or the connection can eavesdropped. (The password
can obfusticated on the wire, but that does not help.)

And in any case, anyone can just copy the database files and attach
them on a server where they have admin rights and do whatever you want
with it.

So while you cannot prevent this, the application role can still serve
the purpose to tell people to keep out, or the warranty will be voided.
But this latter is something you also include in a license agreement.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Monday, March 19, 2012

Create reporting services project in VS 2003

I've installed instance of SQL Server 2005 with reporting services on
my Windows 2003
computer .I've had Visual studio 2003 .After installation i can't
create new reporting
service project in my VS 2003 IDE,but i have now VS 2005 with only
reporting services
project types evalible.I need to work on reporting services in VS
2003.Please tell me how
can i do this.
ThanksHi,
I dont think it is possible in VS 2003. If you have installed Sql server
2005 and their tools you can go through "SQL Server Business Intelligent
studio" you can do report creation.
Regards
Amarnath
"gbletel@.gmail.com" wrote:
> I've installed instance of SQL Server 2005 with reporting services on
> my Windows 2003
> computer .I've had Visual studio 2003 .After installation i can't
> create new reporting
> service project in my VS 2003 IDE,but i have now VS 2005 with only
> reporting services
> project types evalible.I need to work on reporting services in VS
> 2003.Please tell me how
> can i do this.
> Thanks
>

Thursday, March 8, 2012

create new database in analysis service not use BI

i have AAAA project create by BI, now i want to change my computer, so i get XMLA from AAAA project in BI and run it in analysis service XMLA query but it return follow error:
Executing the query ...
Either the user, PCHOME\max, does not have access to the Analysis Services Project1 database, or the database does not exist.

Execution complete

i try another way: i click right mouse on my database from analysis service, so i choice "Script database as "--> CREATE to... and i get a new XMLA file so igo to another computer, and run it, SQL return follow error:
Executing the query ...
Either the user, PCHOME\max, does not have access to the AAAA database, or the database does not exist.

Execution complete
can i solve this problem.
thanks

Another way to do this is to use BI dev studio to import the database and then redeploy to another server

For example

Launch BI Dev Studio

New Project/Business Intelligence Projects/Import Analysis Services 9.0 Database

After loaded, go to project properties and set the target server.

Also you can use the Deployment Wizard under the start menu/SQL Server 2005/Analysis Services/Deployment Wizard

You do need to be an administrator on the target server in order to create a database there.

HTH

-Jamie

|||sorry, i want to create on new computer not connect to my computer, how to export analysis services database to import to another computer

As you said, i have to use

Launch BI Dev Studio

New Project/Business Intelligence Projects/Import Analysis Services 9.0 Database

on my computer and select database on my computer, after that change target server. on properties change server name,



then i go to another computer and open my project on target server?

i can't understand about your idea,

can you explain to me

|||I'm confused now. What is the true goal of what you are trying to accomplish? Are you simply trying to move an Analysis Services database from one machine to another machine? If so, the correct way to do so is to use backup and restore. If you want to move the definition of a database between machines, these other options are the way to go.|||

This link gives more information about the deployment wizard: http://msdn2.microsoft.com/en-us/library/ms176121.aspx which can create a database on Computer B from a project on Computer A

This link gives information about the synchronization wizard which may also be useful: http://msdn2.microsoft.com/en-us/library/ms174488.aspx - it can copy a database from Computer A to Computer B

There also other methods, 5 in total, described here: http://msdn2.microsoft.com/en-us/library/ms175446.aspx

Which method you use will depend on exactly what you would like to acheive. But I think you will find one of these methods suitable.

create new database in analysis service not use BI

i have AAAA project create by BI, now i want to change my computer, so i get XMLA from AAAA project in BI and run it in analysis service XMLA query but it return follow error:
Executing the query ...
Either the user, PCHOME\max, does not have access to the Analysis Services Project1 database, or the database does not exist.

Execution complete

i try another way: i click right mouse on my database from analysis service, so i choice "Script database as "--> CREATE to... and i get a new XMLA file so igo to another computer, and run it, SQL return follow error:
Executing the query ...
Either the user, PCHOME\max, does not have access to the AAAA database, or the database does not exist.

Execution complete
can i solve this problem.
thanks

Another way to do this is to use BI dev studio to import the database and then redeploy to another server

For example

Launch BI Dev Studio

New Project/Business Intelligence Projects/Import Analysis Services 9.0 Database

After loaded, go to project properties and set the target server.

Also you can use the Deployment Wizard under the start menu/SQL Server 2005/Analysis Services/Deployment Wizard

You do need to be an administrator on the target server in order to create a database there.

HTH

-Jamie

|||sorry, i want to create on new computer not connect to my computer, how to export analysis services database to import to another computer

As you said, i have to use

Launch BI Dev Studio

New Project/Business Intelligence Projects/Import Analysis Services 9.0 Database

on my computer and select database on my computer, after that change target server. on properties change server name,



then i go to another computer and open my project on target server?

i can't understand about your idea,

can you explain to me

|||I'm confused now. What is the true goal of what you are trying to accomplish? Are you simply trying to move an Analysis Services database from one machine to another machine? If so, the correct way to do so is to use backup and restore. If you want to move the definition of a database between machines, these other options are the way to go.|||

This link gives more information about the deployment wizard: http://msdn2.microsoft.com/en-us/library/ms176121.aspx which can create a database on Computer B from a project on Computer A

This link gives information about the synchronization wizard which may also be useful: http://msdn2.microsoft.com/en-us/library/ms174488.aspx - it can copy a database from Computer A to Computer B

There also other methods, 5 in total, described here: http://msdn2.microsoft.com/en-us/library/ms175446.aspx

Which method you use will depend on exactly what you would like to acheive. But I think you will find one of these methods suitable.

Wednesday, March 7, 2012

Create login account

I have installed MSDE 2000 on my computer. When I try to use ODBC to connect
to the data source, it keeps asking me to enter User Name and Password. Can
someone please tell me how I can create an account to connect to the SQL data
source?
> I have installed MSDE 2000 on my computer. When I try to use ODBC to
connect
> to the data source, it keeps asking me to enter User Name and Password.
Can
> someone please tell me how I can create an account to connect to the SQL
data
> source?
Here is a good starting point for MSDE security:
http://support.microsoft.com/default...;en-us;325022.
Dejan Sarka, SQL Server MVP
Associate Mentor
Solid Quality Learning
More than just Training
www.SolidQualityLearning.com

Friday, February 24, 2012

CREATE FUNCTION owner_name

Hi,

I have a problem with a function I am creating. I am working on a project for Uni. I coded all my SQL on my home computer, but now I have transferred it all to the schools system and I have a problem with the permissions on the schools SQL Server.

On my home computer I created

CREATE FUNCTION GetDateOnly

It automatically gave it the 'dbo' owner_name which worked fine at home, but on the Uni computers it says I dont have permission to execute it. The owner of all my other Procedures, tables etc. is SCMS/ral6 when I create them at school, which is also the owner_name of my function if I create it at school, but...

If I try and run a function like this:

SCMS/ral6.GetDateOnly()

It does not like the '/'

Nor does it work if I leave that part of, and just go:

ral6.GetDateOnly()

Does anyone know how I can run this? The Uni is not likely to change there whole permissions to run my one project, but without this FUNCTION, my project will not work.

Thankstry [SCMS/ral6].GetDateOnly()|||Cheers for that, I think you just saved my life :)