Latest developer linksBookmark and Share
 
HomeThis WeekTop MonthTop AlltimeSearchRegisterFAQ
  
 
Submit Your Link
Please login to submit your Link
 

Unable to backup database in UserInstance

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:159   Vote Up (0)   Vote Down (0)    

I've been struggling with this for a few days now, so I guess it's time to ask for help.  I'm working on a VB Express 2005 Single form windows application that uses a SQL Express 2005 two table data base.  I can read and write to the database with no problems.  I just can't back it up.  I haven't tried restores yet.  I created the database in SQL Server Management Studio Express and then connected to it from the VB Express application.

My.Settings.UsersConnectionString is

Data Source=.\sqlexpress;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Users.mdf";Integrated Security=True;User Instance=True

I used  the following code to establish a connection to the server that is the userinstance

Dim SqlConnection As SqlClient.SqlConnection = New SqlClient.SqlConnection(My.Settings.UsersConnectionString)

Dim ServerConnection As ServerConnection = New Microsoft.SqlServer.Management.Common.ServerConnection(SqlConnection)

Dim srv As Server = New Server(ServerConnection)

I am able to confirm the connection to the UserInstance via a message box that displays the instance name

MsgBox(srv.InstanceName.ToString)

Then this code follows:

Dim db As Database

db = srv.Databases("USERS")

Dim bk As New Backup

'Specify the type of backup, the description, the name, and the database to be backed up.

bk.Action = BackupActionType.Database

bk.BackupSetDescription = "Full backup of Users"

bk.BackupSetName = "Users Backup"

bk.Database = "USERS"

'Declare a BackupDeviceItem by supplying the backup device file name in the constructor, and the type of device is a file.

Dim bdi As BackupDeviceItem

bdi = New BackupDeviceItem(AppDir & "Test_Full_Backup1.bak", DeviceType.File)

'Add the device to the Backup object.

bk.Devices.Add(bdi)

bk.Initialize = True

'Set the Incremental property to False to specify that this is a full database backup.

bk.Incremental = False

'Set the expiration date.

Dim backupdate As New Date

backupdate = New Date(2008, 10, 5)

bk.ExpirationDate = backupdate

'Specify that the log must be truncated after the backup is complete.

bk.LogTruncation = BackupTruncateLogType.Truncate

'Run SqlBackup to perform the full database backup on the instance of SQL Server.

bk.SqlBackup(srv)

'Inform the user that the backup has been completed.

MsgBox(&qu

View Complete Post


Comments:
Be the first to comment this post.
 
Post Comment
Please login to post your comment
More Related Resources

IIS Issues - Unable to start debugging on the web server. The underlying connection was closed. The connection was closed unexpectedly.

  

All of the sudden I'm getting the following error on my local web server (Win7 64bit, IIS 7.5).  I've uninstalled & reinstalled IIS locally and it didn't fix it.  IIS is set to start up automatically and I can see that the service has been successfully started.  Upon a fresh reboot if I go into IIS and click on start website I get the following error:
"The process cannot access the file because it is being used by another process.  (Exception from HRESULT:  0x80070020"
If I try to start debugging on my local website project I get the following error:
"Unable to start debugging on the web server.  The underlying connection was closed.  The connection was closed unexpectedly."
Any ideas on what I can try?  I've been doing research on the issue and Microsoft suggest making sure no other service is listening on the same ports.  I've verified that this isn't the issue.

All of the sudden I'm getting the following error on my local web server (Win7 64bit, IIS 7.5).  I've uninstalled & reinstalled IIS locally and it didn't fix it.  IIS is set to start up automatically and I can see that the service has been successfully started.  Upon a fresh reboot if I go into IIS and click on start website I get the following error:

"The process cannot access the file because it is being used by another process.  (Exception from HRESULT:  0x80070020"

If I try to start debugging on my local website project I get the following error:

"Unable to start debugging on the web server.  The underlying connection was closed.  The connection was closed unexpectedly."

Any ideas on what I can try?  I've been doing research on the issue and Microsoft suggest making sure no other service is listening on the same ports.  I've verified that this isn't the issue.


IIS Issues - Unable to start debugging on the web server. The underlying connection was closed. The connection was closed unexpectedly.

  

All of the sudden I'm getting the following error on my local web server (Win7 64bit, IIS 7.5).  I've uninstalled & reinstalled IIS locally and it didn't fix it.  IIS is set to start up automatically and I can see that the service has been successfully started.  Upon a fresh reboot if I go into IIS and click on start website I get the following error:
"The process cannot access the file because it is being used by another process.  (Exception from HRESULT:  0x80070020"
If I try to start debugging on my local website project I get the following error:
"Unable to start debugging on the web server.  The underlying connection was closed.  The connection was closed unexpectedly."
Any ideas on what I can try?  I've been doing research on the issue and Microsoft suggest making sure no other service is listening on the same ports.  I've verified that this isn't the issue.

All of the sudden I'm getting the following error on my local web server (Win7 64bit, IIS 7.5).  I've uninstalled & reinstalled IIS locally and it didn't fix it.  IIS is set to start up automatically and I can see that the service has been successfully started.  Upon a fresh reboot if I go into IIS and click on start website I get the following error:

"The process cannot access the file because it is being used by another process.  (Exception from HRESULT:  0x80070020"

If I try to start debugging on my local website project I get the following error:

"Unable to start debugging on the web server.  The underlying connection was closed.  The connection was closed unexpectedly."

Any ideas on what I can try?  I've been doing research on the issue and Microsoft suggest making sure no other service is listening on the same ports.  I've verified that this isn't the issue.


cannot add a new column-Unable to modify table.Invalid object name 'MSED_Logs.DatabaseLog'

  

Dear All,

I cannot add a new column in existing table.

I have a two tables ['ev_event_how' & 'ev_events_event_how'] has relationship between these table.

Ex:
Table: 'ev_event_how'

UID - Event[PK]

 

Ex:
Table: 'ev_events_event_how'

UID - Event[FK] - Desc

I want to add a one more column[IsDelete] in both table. But Sql server is not allowing to add the new column, Showing various errors like

1.cannot add a new column-Unable to modify table.Invalid object name 'MSED_Logs.DatabaseLog'

2.TITLE: Microsoft SQL Server Management Studio
------------------------------

User canceled out of save dialog
 (MS Visual Database Tools)

 

How can I make it add a new column in existing table?

 

 

 

 

 

 

 


How to import existing database into Webmatrix?

  

I am planning to use Webmatrix as a testing arena for creating and completing the preparation of a website before publishing it. Working with websites on local computer should be much faster than doing that on an online server.

That is why I downloaded a database that I have already created on my online host account, and wanted to import it into webmatrix to continue building my new website using Webmatrix. Here, I did not know how to imort the DB I downloaded from my host, into webmatrix. There is seemingly no way to do that, or to import tables into an existing DB on webmatrix. 

Is that not possible? 

2- I tried to create a new DB on webmatrix which is a part of installing Wordbress on WM (new site from web gallery --> Wordpress), but I get this error :

The database 'xxxx' could not be created. ---> MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts. ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:3306


I have installed PHP 5.2 and Mysql on Webmatrix. 


Why does this happen?


Unable to run .cshtml in Webmatrix beta 3

  

After creating a Empty Template based website with a default .cshtml, I am unable to run the web page using webmatrix beta 3.

Following error message I have :


Server Error in '/' Application.

Specified argument was out of the range of valid values.
Parameter name: site

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +238

[HttpException (0x80004005): Specified argument was out of the range of valid values.
Parameter name: site]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8950644
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +256


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1


Please let me how to resolve this!! 


how to open a database in a webmatrix C# file?

  

In the webMatrix examples, which I have working, it's very easy to access a database. Only three lines are necessary to get up and going:

@{ 
    var db = Database.Open("LOS");  
    var selectQueryString = "SELECT * FROM wknTest"; 
} 

and a little later,

 @foreach(var row in db.Query(selectQueryString)){  

There's no using's, no connection strings, all that happens behind the scenes. But now I have enough complicated c# code that I want to separate it into a separate C# file. How would I do the above, but in a C# file residing in the app_code folder in a webMatrix project? 

WebMatrix must be creating the Database object behind the scenes.  So I'm really asking how do I have access to that.


Webmatrix.Data.Database.Query() method return type

  

I'm using the Webmatrix.Data.Database.Query method to return a result set in the following form

var myResult = db.Query("Select * from mytable");

How do you cast myResult to get the count of records returned? I'd like to do something like

   myResult.Count


Login Control with SQL Database

  

Hello,

I'm in a trouble with the Login Control of ASP.NET to check the credentials against an SQL Database.

I followed all the instructions from http://www.aspxcode.net/free-asp-net-login-source-code.aspx?Topics=How to Login With SQL Server Database but I have errors.

 

In a master page, I added a Login Control as follows:

<asp:LoginView ID="LoginView1" runat="server">
                <AnonymousTemplate>
                    <asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate" BorderPadding="0"
                        BorderStyle="None" BorderWidth="0px" EnableTheming="True" Font-Names="Arial"
                        Font-Size="X-Small" ForeColor="#333333" LoginButtonImageUrl="~/imgs/nav/en/Login.gif"
                        LoginButtonType="Image" TitleText="" TextLayout="TextOnTop" Width="120px" RememberMeText="Remember me.">
                        <CheckBoxStyle VerticalAlign="Middle" HorizontalAlign="Left" />
                        <InstructionTextStyle Font-Italic="True" ForeColor="Black" />
                        <LabelStyle HorizontalAlign="Left" Width="130px" />
                        <LoginButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="None" Font-Names="Arial"
                            Font-Size="X-Small" ForeColor="#284775" CssClass="loginBox" />
                        <TextBoxStyle Font-Size="X-Small" Width="120px" />
                        <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" Font-Size="X-Small" ForeColor="White" />
                    </asp:Login>               
                </AnonymousTemplate>
                <LoggedInTemplate>
                    <asp:LoginName ID="LoginName1" runat="server" /><br />
                    <asp:LoginStatus ID="LoginStatus1" runat="server" />
                </LoggedInTemplate>
                </asp:LoginView>

 

Also, I have implemented an internet found class to the project to connect, OnAuthenticate, to the SQL Database. The code is the following:

Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.Configuration

Partial Class how_to_login_with_sql_server
    Inherits System.Web.UI.MasterPage

 &nb

When choosing POCO, First Model or the EDMX created from the database?

  

Good morning, this is my first post here.

I will make a system that will be sold at retail, placed in the clouds. The EDMX created from the database seemed the most natural choice since in reality the database exists and is already populated, it has a lot of data.

The First Model did not seem a natural solution since it is difficult today a completely new solution, and the examples I saw did not show me because I use it.

About POCO, what advantages do I have using it?

Thanks,

Bruno


Unable to connect. Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. Check Web.config file "ConnectionString" setting.

  

Hi,

I am getting this error:

Unable to connect.
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Check Web.config file "ConnectionString" setting.


anybody knows the solution?


thanks in advance.




 
Categories:
.NET
Java
PHP
C/C++/VC++
HTML/XML
SAP
MainFrames
Data Warehousing
Testing
MySQL
SQL Server
Oracle
Javascript/VB Script
Others
Login
 
 
 
 
 Forgot password
 Contact Us   Terms Of use   Share your knowledge