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

Failed to update database because the database is read-only.

Posted: Jan/22/2011   By: nikhil   Points:15   Category: .NET  - ASP.Net    Views:215   Vote Up (0)   Vote Down (0)    
I am building a Windows Forms application in VS 2005, using C# and SQL Server 2005 Express as the backend.

When I try to accessd data from the db, it works with no problems.

When I try to insert/update/delete, I get the following error message

Failed to update database "DBNAME" because the database is read-only.

I am using a connection string with the following syntax:
"Data Source=.\SQLEXPRESS;AttachDbFilename=c:\PATH_TO_DB\db.mdf;Database=MyDB;Integrated Security=False;User Instance=False;User ID=USR;Password=PWD;"

I have made sure that the permissions on the DB are set (in Windows) so that all users can modify. The user that is logging in to the DB has status set to DBOWNER.

I have seen others experience the same problem - with ASP.net sites, not Windows Forms sites (thus most of their solutions dont apply to me)

Any ideas on what is wrong and how I can get this to work?

View Complete Post


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

How to format and update GridView and DataGrid rows using JQuery

  
The behavior described in this question is as expected. When you set text of a cell in grid, it directly affects HTML that is going to be rendered. When you set text value of a cell, it means that you are setting innerText of the cell. The column that GridView creates for command fields (Edit, Delete and Select) are a (anchor) or button elements. So you can see what will happen if you set text value in that cell. It will wipe out those link or button controls and replace them with simple text string.

Cannot insert the value NULL into column 'COUNTY', table 'TPI.dbo.juror_tmp'; column does not allow nulls. UPDATE fails.

  

I am attempting to bind data from a dropdown list that was populated from another datasourceID. I've bolded what I believe is relevant to this issue in the code below. But basicly its binding the proper county on the pull down menu but when I hit form submit it dosnt postback that info instead its null.

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1"
            style="margin-right: 59px"
           CellPadding="4"
            ForeColor="#333333" DefaultMode="Edit" DataKeyNames="UID">
            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
            <EditItemTemplate>
                Edit Item Template<br /><asp:Label ID="uidlabel" runat="server" Text='<%# Bind("uid") %>' /><br />
                last_date ha:
                <asp:TextBox ID="last_dateTextBox" runat="server"
                    Text='<%# Bind("last_date", "{0:d}") %>' AutoPostBack="True"
                    CausesValidation="True" />
                <br />
                first_name:
                <asp:TextBox ID="first_nameTextBox" runat="server"
                Text='<%# Bind("first_name") %>'
                    CausesValidation="True" ontextchanged="first_nameTextBox_TextChanged1" />
                <br />
                last_name:
                <asp:TextBox ID="last_nameTextBox" runat="server"
                    Text='<%# Bind("last_name") %>'
                    AutoPostBack="True"
                    CausesValidation="True" />
                <br />
                mi:
                <asp:TextBox ID="miTextBox" runat="server" Text='<%# Bind("mi") %>'
                    AutoPostBack="True" CausesValidation="True" MaxLength="1" />
                <br />
                home_phone:
                <asp:TextBox ID="home_phoneTextBox" runat="server"
                    Text='<%# Bind("home_phone") %>' MaxLength="9&

Manually Calling Update on ObjectDataSource Causing Multiple Updates

  

I have GridView that is bound to an ObjectDataSource and within that GridView I have CheckBox, DropDownList, TextBox and Label controls.  All the controls except the CheckBoxs are working like a champ or normal display and Delete (Insert is handled outside the GridView, it works also). 

The CheckBox values are passed into the update method for the ObjectDataSource as type byte.  Without doing any custom coding the CheckBoxs were always unchecked (regardless of the data being 1 or 0)  and when I edit a row in the GridView and saved the values the CheckBox controls would always be 0 even if the check boxes where checked. 

After searching web I found a suggestion to change the binding on the CheckBox controls from, Bind("Monday") to this, CheckUncheck(DataBinder.Eval(Container.DataItem, "Monday")) with CheckUncheck being a method to make 0 or null = false and 1 = true.  This seemed to the do the trick and it set the CheckBoxs correctly in the DataGrid, I was giving myself high-fives, until. I tried to update a row. 

When doing the update, as with my first attempt, it would always set the CheckBox values to 0, thus ignoring the checked property of the CheckBox.  So I search the web again and found a suggestion to handle the update manually, due to the binding being one way. So I created a myUnhappyGrid_RowUpdating event handler and changed all the columns in the GridView to template so I could do the old school .FindControl on them and grab the values.  Once I was able to grab the values from the row to be updated I added them to the ObjectDataSource .UpdateParameters and called ObjectDataSource.Update() and it worked, kind of. 

Now came the next trial, it did the update into the database just fine and I was happy, until..  I finished stepping though the code.  As I stepped through the code the update on the ObjectDataSource got called two more times, thus undoing what I had just spent hours fixing.

First, is the road traveled the right way to do it?

Second, if I am on the correct road how can I suppress the additional two updates that follow my manual .update call on the ObjectDataSource?

Please help!


AJAX UPDATE PANEL GET REFRESH EVEN JQUERY BUTTON CLICK RETURN FALSE

  

Hi !

I want to pop up a password text box and ask the user to enter the password again before procedding to retrieve a report.

However, my button keep submitin to the server to get a report.

I use AJAX Update Panel that contain a grid view and a button trigger the grid view to be filled in.

I use jquery to pop up a dialog box and even i return false on the click even, the update panel is still get updated before the user fill in a password.

How do i make sure the click event that pop up a dialog box come first before any other click event ?

        Sys.Application.add_load(function() {
            $("#dialog:ui-dialog").dialog("destroy");

            $("#dialog-modal").dialog({
                height: 140,
                modal: true,
                autoOpen: false,
                buttons: {
                    "OK": function() {
                        var passwordtxtbox = $('#<%=PasswordTxtBox.ClientID%>').val();
                        if (passwordtxtbox != "" && passwordtxtbox.length > 0) {
                            $(this).dialog("close");
                            return true;
                        }

                    }
                }
            });

            $("#<%=Search.ClientID%>").click(function() {
                $("#dialog-modal").dialog("open");
                return false;
            });

 


"Failed to create AppDomain"

  

Hello,

When I click on execution of asp.net application, when loading of page on browser, I get following exception error message:

"Failed to create AppDomain"

despite search results via google on this following steps dealing with renaming of security.config or doing  caspol -reset didn't work:

http://forums.asp.net/t/1304604.aspx

http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2005/03/16/5345.aspx

Is there any other idea how to fix this? I can't help this, I've googled enough.

I previously had Visual Studio 2008 installed. Now I have Visual Studio 2010 besides Visual Web Developer express 2010 installed. Can this be problem? I don't know at all what to do.

Thank for your answers.

Failed to create AppDomain


Failed to generate a user instance of SQL Server

  

 I am creating asp.net forms authentication. When I run web site and there I try to create new user I get this error:

Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.

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.

SQLExpress database file auto-creation error:

The connection string specifies a local Sql Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The following configuration requirements are necessary to successfully check for existence of the application services database and automatically create the application services database:

  1. If the applications App_Data directory does not already exist, the web server account must have read and write access to the applications directory. This is necessary because the web server account will automatically create the App_Data directory if it does not already exist.
  2. If the applications App_Data directory already exists, the web server account only requires read and write access to the applications App_Data directory. This is necessary because the web server account will attempt to verify that the Sql Server Express database already exists within the applications App_Data directory. Revoking read access on the App_Data directory from the web server account will prevent the provider from correctly determining if the Sql Server Express database already exists. This will cause an error when the provider attempts to create a duplicate of an already existing database. Write access is required because the web server accounts credentials are used when creating the new database.
  3. Sql Server Express must be installed on the machine.
  4. The process identity for the web server account must have a local user profile. See the readme document for details on how to create a local user profile for both machine and domain accounts.


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:

[SqlException (0x80131904): Failed to generate a user instance of SQL Server due to a failure in starting the process for the user instance. The connection will be closed.]
   System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) +4846887
   System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) +194
   System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2392
   System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK) +35
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +144
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +342
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +4861315
   System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup) +29
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +4863644
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   System.Web.Manage 

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?


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


Failed to grant minimum permission requests

  

I am getting this error on my web site and it is preventing the site from compiling.  The site is in full trust and the web site files are on the local drive.  Web searches show that the only two issues are full trust not enabled or the files on a UNC path that is not trusted and neither is the case here.   This site is on an Win2008/IIS7 server.  Anyone have any ideas as to why this is happening or where to look for other trust level or security settings to resolve this.


 
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