Showing posts with label connected. Show all posts
Showing posts with label connected. Show all posts

Friday, March 30, 2012

restrict delete function on odbc connection

i have the odbc connection connected to our SQL databasse via sql user
account through MS access Frontend and having problem controling the delete
function of the account.

In SQL i am only allow the account to read, insert,update and denied delete
on the database and tables. However, the account still be able delete the
records.

Can someone let me know what am i missing in the permission granting.

Check individual permissions, groups permissions and what is important the permissions granted to the public role where every database user will be added to.

Jens K. Suessmeyer

http://www.sqlserver2005.de

Saturday, February 25, 2012

Restoring DB for files...

Hi
In order to copy a database from a server to a server, I cant detach the database as there are many users connected to it. The transaction log is large file while the data is about 46 MB, I made a backup for the data file only, zipped it and copied it to the target server.
Ex: the name of the source DB on the source server is x, the file I took as a backup for is x-data
From the Enterprise Manager, right-click the x DB, All tasks, Backup database, in the backup option click the File and Filegroup option and chose the primary file group with x_data file.
Then, I created a new database name it y with y_data , y_log files on primary filegroup. I want to restore my backup to have the DB x on my target server,
I tried:
RESTORE DATABASE y
FILE = 'y_data',
FILEGROUP = 'primary'
FROM disk= 'E:\VMS\DBFiles\test'
GO

But it did not work. Any help?

Thanks,what is the error you are getting ?

Tuesday, February 21, 2012

Restoring database problem

Hello All,
I tried to restore a msde database file in c#. Since SQL Server
requires that no users be connected to the database during the restore
operation, I tried to shut down the sql server, then start the sql
server again. Unfortunately, it did not work. The following is the
code:
//create an instance of a server class
SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
//connect to the server
srv.Connect("local)\\NetSDK", "sa", "abc");
try
{
srv.Shutdown(5000); // stop db server, wait for 2 seconds
}
catch (Exception e)
{
; // do nothing
}
Thread.Sleep(10000); // sleep 10 seconds
// restart server
srv.Start(true, "(local)\\NetSDK", "sa", "abc");
//create a restore class instance
SQLDMO.Restore restore = new SQLDMO.Restore();
restore.Action = 0; // full db restore
//set the database to the chosen database
restore.Database = "mydbfile";
restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
uid=sa; password=abc; pooling=false");
// Restore the database
restore.ReplaceDatabase = true;
restore.SQLRestore(srv);
An exception is thrown at srv.Start with message:
"An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in myapp.exe
Additional information: [SQL-DMO]This server object is already
connected."
Mandy
Mandy wrote:

> Hello All,
> I tried to restore a msde database file in c#. Since SQL Server
> requires that no users be connected to the database during the restore
> operation, I tried to shut down the sql server, then start the sql
> server again. Unfortunately, it did not work. The following is the
> code:
> //create an instance of a server class
> SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
> //connect to the server
> srv.Connect("local)\\NetSDK", "sa", "abc");
> try
> {
> srv.Shutdown(5000); // stop db server, wait for 2 seconds
> }
> catch (Exception e)
> {
> ; // do nothing
> }
> Thread.Sleep(10000); // sleep 10 seconds
> // restart server
> srv.Start(true, "(local)\\NetSDK", "sa", "abc");
> //create a restore class instance
> SQLDMO.Restore restore = new SQLDMO.Restore();
> restore.Action = 0; // full db restore
> //set the database to the chosen database
> restore.Database = "mydbfile";
> restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
> SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
> uid=sa; password=abc; pooling=false");
> // Restore the database
> restore.ReplaceDatabase = true;
> restore.SQLRestore(srv);
>
> An exception is thrown at srv.Start with message:
> "An unhandled exception of type
> 'System.Runtime.InteropServices.COMException' occurred in myapp.exe
> Additional information: [SQL-DMO]This server object is already
> connected."
And if you use the T-SQL commands instead of SQLDMO? (RESTORE DATABASE) You
could even shutdown the mssqlserver process through executing "net stop
mssqlserver" as a process and then restart it again with "net start
mssqlserver" as a process.
FB
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP
|||Hi,
Thanks for replying! How to execute T-SQL commands to stop and start
database in C#?
Mandy
"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@.xs4all.nl> wrote in message news:<xn0dnlsxj3398s001@.msnews.microsoft.com>...
> Mandy wrote:
>
> And if you use the T-SQL commands instead of SQLDMO? (RESTORE DATABASE) You
> could even shutdown the mssqlserver process through executing "net stop
> mssqlserver" as a process and then restart it again with "net start
> mssqlserver" as a process.
> FB
|||Mandy wrote:
> Thanks for replying! How to execute T-SQL commands to stop and start
> database in C#?
stop and start the server process. You can do that through:
// stopping
System.Diagnostics.Process.Start("CMD.exe", "/C net stop mssqlserver");
// starting
System.Diagnostics.Process.Start("CMD.exe", "/C net start mssqlserver");
Of course you have to wait some seconds between the two.
Frans.[vbcol=seagreen]
> Mandy
>
> "Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@.xs4all.nl> wrote in message
> news:<xn0dnlsxj3398s001@.msnews.microsoft.com>...
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP

Restoring database problem

Hello All,
I tried to restore a msde database file in c#. Since SQL Server
requires that no users be connected to the database during the restore
operation, I tried to shut down the sql server, then start the sql
server again. Unfortunately, it did not work. The following is the
code:
//create an instance of a server class
SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
//connect to the server
srv.Connect("local)\\NetSDK", "sa", "abc");
try
{
srv.Shutdown(5000); // stop db server, wait for 2 seconds
}
catch (Exception e)
{
; // do nothing
}
Thread.Sleep(10000); // sleep 10 seconds
// restart server
srv.Start(true, "(local)\\NetSDK", "sa", "abc");
//create a restore class instance
SQLDMO.Restore restore = new SQLDMO.Restore();
restore.Action = 0; // full db restore
//set the database to the chosen database
restore.Database = "mydbfile";
restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
uid=sa; password=abc; pooling=false");
// Restore the database
restore.ReplaceDatabase = true;
restore.SQLRestore(srv);
An exception is thrown at srv.Start with message:
"An unhandled exception of type
'System.Runtime.InteropServices.COMException' occurred in myapp.exe
Additional information: [SQL-DMO]This server object is already
connected."
MandyMandy wrote:
> Hello All,
> I tried to restore a msde database file in c#. Since SQL Server
> requires that no users be connected to the database during the restore
> operation, I tried to shut down the sql server, then start the sql
> server again. Unfortunately, it did not work. The following is the
> code:
> //create an instance of a server class
> SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
> //connect to the server
> srv.Connect("local)\\NetSDK", "sa", "abc");
> try
> {
> srv.Shutdown(5000); // stop db server, wait for 2 seconds
> }
> catch (Exception e)
> {
> ; // do nothing
> }
> Thread.Sleep(10000); // sleep 10 seconds
> // restart server
> srv.Start(true, "(local)\\NetSDK", "sa", "abc");
> //create a restore class instance
> SQLDMO.Restore restore = new SQLDMO.Restore();
> restore.Action = 0; // full db restore
> //set the database to the chosen database
> restore.Database = "mydbfile";
> restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
> SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
> uid=sa; password=abc; pooling=false");
> // Restore the database
> restore.ReplaceDatabase = true;
> restore.SQLRestore(srv);
>
> An exception is thrown at srv.Start with message:
> "An unhandled exception of type
> 'System.Runtime.InteropServices.COMException' occurred in myapp.exe
> Additional information: [SQL-DMO]This server object is already
> connected."
And if you use the T-SQL commands instead of SQLDMO? (RESTORE DATABASE) You
could even shutdown the mssqlserver process through executing "net stop
mssqlserver" as a process and then restart it again with "net start
mssqlserver" as a process.
FB
--
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP|||Hi,
Thanks for replying! How to execute T-SQL commands to stop and start
database in C#?
Mandy
"Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@.xs4all.nl> wrote in message news:<xn0dnlsxj3398s001@.msnews.microsoft.com>...
> Mandy wrote:
> > Hello All,
> >
> > I tried to restore a msde database file in c#. Since SQL Server
> > requires that no users be connected to the database during the restore
> > operation, I tried to shut down the sql server, then start the sql
> > server again. Unfortunately, it did not work. The following is the
> > code:
> >
> > //create an instance of a server class
> > SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
> > //connect to the server
> > srv.Connect("local)\\NetSDK", "sa", "abc");
> > try
> > {
> > srv.Shutdown(5000); // stop db server, wait for 2 seconds
> > }
> > catch (Exception e)
> > {
> > ; // do nothing
> > }
> >
> > Thread.Sleep(10000); // sleep 10 seconds
> > // restart server
> > srv.Start(true, "(local)\\NetSDK", "sa", "abc");
> >
> > //create a restore class instance
> > SQLDMO.Restore restore = new SQLDMO.Restore();
> > restore.Action = 0; // full db restore
> > //set the database to the chosen database
> > restore.Database = "mydbfile";
> > restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
> >
> > SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
> > uid=sa; password=abc; pooling=false");
> >
> > // Restore the database
> > restore.ReplaceDatabase = true;
> > restore.SQLRestore(srv);
> >
> >
> >
> > An exception is thrown at srv.Start with message:
> >
> > "An unhandled exception of type
> > 'System.Runtime.InteropServices.COMException' occurred in myapp.exe
> >
> > Additional information: [SQL-DMO]This server object is already
> > connected."
> And if you use the T-SQL commands instead of SQLDMO? (RESTORE DATABASE) You
> could even shutdown the mssqlserver process through executing "net stop
> mssqlserver" as a process and then restart it again with "net start
> mssqlserver" as a process.
> FB|||Mandy wrote:
> Thanks for replying! How to execute T-SQL commands to stop and start
> database in C#?
stop and start the server process. You can do that through:
// stopping
System.Diagnostics.Process.Start("CMD.exe", "/C net stop mssqlserver");
// starting
System.Diagnostics.Process.Start("CMD.exe", "/C net start mssqlserver");
Of course you have to wait some seconds between the two.
Frans.
> Mandy
>
> "Frans Bouma [C# MVP]" <perseus.usenetNOSPAM@.xs4all.nl> wrote in message
> news:<xn0dnlsxj3398s001@.msnews.microsoft.com>...
> > Mandy wrote:
> >
> > > Hello All,
> > >
> > > I tried to restore a msde database file in c#. Since SQL Server
> > > requires that no users be connected to the database during the restore
> > > operation, I tried to shut down the sql server, then start the sql
> > > server again. Unfortunately, it did not work. The following is the
> > > code:
> > >
> > > //create an instance of a server class
> > > SQLDMO.SQLServer srv = new SQLDMO.SQLServer();
> > > //connect to the server
> > > srv.Connect("local)\\NetSDK", "sa", "abc");
> > > try
> > > {
> > > srv.Shutdown(5000); // stop db server, wait for 2 seconds
> > > }
> > > catch (Exception e)
> > > {
> > > ; // do nothing
> > > }
> > >
> > > Thread.Sleep(10000); // sleep 10 seconds
> > > // restart server
> > > srv.Start(true, "(local)\\NetSDK", "sa", "abc");
> > >
> > > //create a restore class instance
> > > SQLDMO.Restore restore = new SQLDMO.Restore();
> > > restore.Action = 0; // full db restore
> > > //set the database to the chosen database
> > > restore.Database = "mydbfile";
> > > restore.Files = Path.GetFullPath(@."..\..\backup\DBLPS.bak");
> > >
> > > SqlConnection conn = new SqlConnection("server=(local)\\NetSDK;
> > > uid=sa; password=abc; pooling=false");
> > >
> > > // Restore the database
> > > restore.ReplaceDatabase = true;
> > > restore.SQLRestore(srv);
> > >
> > >
> > >
> > > An exception is thrown at srv.Start with message:
> > >
> > > "An unhandled exception of type
> > > 'System.Runtime.InteropServices.COMException' occurred in myapp.exe
> > >
> > > Additional information: [SQL-DMO]This server object is already
> > > connected."
> >
> > And if you use the T-SQL commands instead of SQLDMO? (RESTORE DATABASE)
> > You could even shutdown the mssqlserver process through executing "net
> > stop mssqlserver" as a process and then restart it again with "net start
> > mssqlserver" as a process.
> >
> > FB
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET Blog: http://weblogs.asp.net/fbouma
Microsoft C# MVP