Cannot Connect To Database After Exiting The Program.
Mar 6, 2008
Hello,
I have been writing this piece of software for quite a while. And as it got bigger and bigger (more forms, more datasets) I started experiencing the following problem.
Well, I use an MDF file as a database container that gets copied to the destination directory after each build.
Well here is what happens:
I launch my application, work with it, search the database and so on and so on.
Then I exit the application.
I launch it again and I get en exception saying that file counld not be located on the disk.
I close the app, and run it again. I get the same thing.
Somtimes after a couple of tries I get an error saying that my user does not have rights to access the default database. (I have windows authentication on SQL server)
Now here is the trick: I open SQL Server Management Studio Express detatch (Delete) the database from the default server (the only one in the system ".SQLEXPRESS") and the application runs again.
What am I doing wrong? How can I programatically detatch the database from the server (Maybe some sql command)? Do I need it though?
This is the connection string that I use for connection:
Code Snippet
Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MyAppDB.mdf;Integrated Security=True;Connect Timeout=10;User Instance=False
But the confusing part of it is that it happend on my work computer and not on my home computer. I have the same User/Password/Workgroup/VS version/MS SQL versoion/Windows version on both machines.
Is there a way that upon exiting VSS I can be warned if I have programs checked-out, so that I don't leave for vactaion with an important program checked-out?
I am developing a program to connect to SQL 2005 Express. I don't know if I need any CAL license in order to make the connection. If it is not necessary for the Express Edition case, how about if my client upgrate to SQL 2005 in the future? Do I need CAL license for SQL 2005?
what the program will do if we caught that exception .. i need some suggestions ... i got this exception(String or binary data would be truncated. The statement has been terminated.).. will it affect the functionality of the program...
I have an existing publication and I want to modify an index on my main server. I do not want the index to be pushed out to the other server, but I'm wondering if the index will break replication.Any thoughts?
CREATE PROCEDURE [dbo].[WWspLoadData] @Planid varchar(5), @OverMar int = Null
need to check here if the @PlainID exists in the tbOldCustomers.PlainID if it does exists then do nothing and exit the store procedure, and if it does not exists continue to the rest of the store procedure.
An Execute SQL task returns one row with two values that are correctly stored into variables.
Based off those two variables, a sequence container is chosen to execute.
That sequence container then does magic. The last step of the container has an execute SQL task that runs and stores the result in a variable - let's call this[User::result] with type Int32.
Based off the value in [User::result] one of two final tasks run. A non zero value executes one task; a zero value executes another. Basically,SOMETHING runs after this.
Simple? I thought so... except Step 4 doesn't work. If I set a post-execute breakpoint on the sequence container, the variables are populated as expected, but nothing else runs. If I add another task to run (without a conditional expression) to run after the sequence container completes, the pre-execute breakpoint shows the data looking exactly as I expect.
Those script tasks are just MessageBox.Show calls and the expression, as you can see, doesn't use variables at all.
I am currently writing a program that will use a SQL database. I am use to writing programs that are used to connect over some type of a network, but for this project I need to be able to load the Database and it's tables to the system locally. If anyone has a suggestion it will be greatly appreciated, or any sites for documentation on it. Thank you.
I have written a program using vb 2005 express that will create menu items after the user presses a particular button. So if the user picks a mountain dew then inside the reciept window(list box) the user will see 1 MT DEW $1.00 also as the user selects more items the price is calculated and displayed also.
This part of the program works fine. After using the program for a while I realized that I will need to update prices and be able to add and subtract items from the menu that customers order from. The way I accompolish this now is to go back into my code and rewrite alot of code. From reading the forums I think that a database would be a good solution because what I have gathered so far is that by seperating the data into tables i.e price_table it would be easy to update anything in that table and not have to change the code anywhere else.
I have created a database that contains a table for menu items and each item has a menu_item ID,menu_Name and I also have a Price table and each price now has it's own price_ID
I would like to have code under the button click event like so:
createMenuItem(By Val Food_ID as Database object, By Val Price_ID As Database object)
display(Quantity,Food_Name,Food_Cost)
Food_Cost = Quantity * Price_ID
I know that this code does not work but If someone reading this has any ideas which part of database programming this falls under I could use a nudge in the right direction.
In a nutshell I would like to create menu items using the id's from the database
the data in the database would remain static and would only be used to supply arguements for my procedures and function that I use now.
hi. When i click on the button, it will go to another page called fileB.aspx, it will query database based on textbox parameter from fileA.aspx and display gridview on fileB.aspx It is based on sqldatasource. abit noob on programming visual basic.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click 'Code go here.End Sub
I am reading a guide telling how to create a private server and it says I need to restore the database. So I go to File->Open->File->My Computer->Local Disk->Program Files->Microsoft SQL Server->MSSQL.1->MSSQL->Data->GunzDB. Then the following message comes up: "The file cannot be opened because it is being used by another process. Please close all applications that might access this file and try again."
The question is, how do I get past this? I need the answer as soon as possible, I am a newb with this program so I don't entirely know what I am doing. I have tried searching for the answer, but I cannot find anything.
the idea is to put together a folder that is in some place in the computer, like "c:excel_fles" and the database full backup in a single .bak file, the database can be recovered with sql server management studio(but no the folder), the restoration of the program can be done with a program, I think it can be done with msdb, but I'm a little lost in the road.
We want to deny access to sql server 2005 database by the sql management studio or any other sql editor while our developed application can access the database even malicious user gets the login name and password by disassembling our code
I have an application that creates a new database during installation,and I've noticed some strange behavior. Once I've created thedatabase, I am able to immediately create tables and populate lookupdata, provided I remain connected to the server. If, however, Idisconnect and attempt to reconnect immediately, I'll get an errorsaying that my login is invalid for the new database.I can get around this by having my code simply wait 5 seconds beforeattempting to reconnect, but I'm curious to see if anybody here cangive an explaination for why this is happening. Here is a bit ofpseudo code to explain what I'm seeing:open new connectioncreate databasecreate tablespopulate tablesclose connection// open new connection /* can't do this yet, as it would break */for (int a=0; a<5; a++){Thread.Sleep(2000)try{open new connectionbreak;}catch{Debug("still waiting...");}}Running my version of this code, I'll see that "still waiting..."message go past 2-3 times before SQL Server wakes up and realizes thatI'm allowed to connect to it. Anybody know why?Thanks,Jason KesterExpat Software Consulting Serviceshttp://www.expatsoftware.com/---Get your own Travel Blog, with itinerary maps and photos!http://www.blogabond.com/
I was able to connect to the SQL Database Pension with table clients with table values: ID, State, Name.'Create(connection)Dim conn As New Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)'open connectionconn.Open()However, I'm not sure how to insert a new row with an incremental ID number and a new State and Name.Sorry, I'm really new with VWD.
I am new to windows apps in .net 2.0. I am trying to create a windows service that will connect to a database and email info out to people that have had status changes. Right now, I can not connect to the database. Here is the connection string: Private cnn As New SqlClient.SqlConnection("Data Source=IPAddress;Initial Catalog=TheServer;Persist Security Info=True;User ID=userid;Password=password provider=SQLOLEDB.1;connect timeout=3600") This is how I am trying to connect: cnn.Open() myCMD.CommandTimeout = 0 dr = myCMD.ExecuteReader
I keep getting an error message that I can not be logged on. I know that the credentials are correct because I use them for the web app. Something has to be wrong with my connection string, but what? Thanks, enak
I'm using Visual Web Developer and SQL 2005...It Guives me this error...: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) I'm tired of guetin and search solution for this errorI've tried everything that i searched over the "net"...made all the configurations possible in sql server 2005 and nothing...Is this right? Or do i need to put some more code in this line or in server is it "localhost:****...: ...connection = New SqlConnection("Server=servernameWebSite1uid=sa;pwd=1234;database=cdcollection")connection.Open()...... Don't know why in sql server i have two object explorer connections when i start the sql server...one is "servername"...two is "servernamesqlexpress" (but when trying to connect with "servernamesqlexpress" it won't let me, only with "servername")...i use the windows authentication......when i had the VB.NET 2003 and SQL Server 2000, it was much easy to do this... In ASP.NET config i still have the C:inetpubwwwroot path but the files don't go there...now they go to my documentsVisual studio 2005 by default of Visual Web Developer prog. Do i need to change the location? Please help...i'm really desperate...with this...
I am developing my first website for my boss. I am trying to connect to an access database which I have created a DSN for on the server. I am using the following code sample.... //Connection String 1string dsn_name = "access_WALLINVEN.dsn";string sDSNDir = Server.MapPath("_dsn");string connectstr = ("Data Source="+ (sDSNDir + ("\" + dsn_name)));//Connection String 2string connectstr = "Data Source=/jwallpaint/_dsn/access_WALLINVEN.dsn;Uid=jwallpaint;Pwd=J2512wall;";string commandString = "Select * from Inventory";//Pass strings to sqlDataAdapter constructorSqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, connectstr);//Create a datasetDataSet dataSet = new DataSet();//fill the dataset objectdataAdapter.Fill(dataSet, "Inventory");//Get the table from the datasetDataTable dataTable = dataSet.Tables["Inventory"];//Bind to the gridviewGridView1.DataSource = dataTable;GridView1.DataBind();For Connection String 1 I get the error of...An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) For Connection String 2 I get the error of...An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) I am not sure which connection string to use either....It is strange to me that I get this error talking about SQL Server when I am trying to reach my Access database......Any Help?? Thanks....
Hi, I'm on lesson 7 of the Bob Tabor video tutorial called 'Data binding to user interface controls'. Whenever I try to add an SQL database (add new item/sql database) I get the following error message: TITLE: Connect to Server ------------------------------
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) (Microsoft SQL Server, Error: -1) I have VWD installed, sqlexpress installed, everything really. Any help would be appreciated. MD
I am attempting to connect to a database that has been uploaded to my server from my webpages on the server. This is the connection string that is currently used: connectionString="Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Restaurants.mdf;Integrated Security=True;User Instance=True" When attempting to connect to the database I receive this error message: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) I realize that I cannot make a remote connection using SQL Server 2005 Express Edition, but cannot find the proper connection string for it to connect to the uploaded database. Accessing the database doesn't require a log on by the user as all the information is public. The authentication mode in the web.config file is set to "Forms". If there is any other information required so that this problem can be solved, please ask for it. Thank you in advance, Me
when i run application from visual studio im getting this error. Server Error in '/' Application. Cannot open database "Products" requested by the login. The login failed. Login failed for user 'GAMERKALESH'. when run from web browser: Server Error in '/' Application.Cannot open database "Products" requested by the login. The login failed.Login failed for user 'GAMERASPNET'. my comp name is: Gamerand acc name is : Kalesh using Microsoft Studio Server Management studio express i have added these accs:in security of databas products: ASPNET and IUSR_GAMER in general security i have added accs: GAMERASPNET and GAMERIUSR_GAMER using windows authentication.
I just did a ton of work in SQL Server Management Studio Express and now I want to access the database from a Web Developer 2005 Express Edition application. Can't find any documentation on how to connect to the database from vwd. Any assistance would be appreciated. Thanks, Tom
Ok I have several sites on a server that have connected to databases on a different server for a long. Out of the blue today none of the sites on the server can connect to any databases on the other server. However, sites on other servers can connect to databases on the same db server.This is the message I get:An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)The database server runs SQL Server 2000 not 2005 I can connect to the database from desktop (with an asp.net application or sql server management studio), I can ping the database server fine from the production web server, but my applications can't connect for some reason. There is nothing in the event log to suggest a problem, any ideas what could be causing this?
Hello, I have posted awhile ago about this issue, but after taking the advice and trying to get help from GoDaddy, nothing has worked yet. I am using the user login control, and then I changed the connection string in the web config file according to what Go Daddy's help file said, making sure to make proper server, id, and password names. It still won't go through, can anyone help?
I am new learner of ASP.NET and coding in C#.I am not able to connect the SQL database.I have written the code for connection of database but to write the connection string web.config file is neccessary which is not apearing in my application. Please help me .Here is code I have written.
string sCon = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();SqlConnection oCon = new SqlConnection(sCon); try { oCon.Open();string sQuery = "Select Offering1,Offering2,Offering3 from Offering";SqlCommand oCmd = new SqlCommand(sQuery, oCon); oCmd.ExecuteNonQuery(); DataSet oDs = new DataSet();SqlDataAdapter oDa = new SqlDataAdapter(oCmd); oDa.Fill(oDs); DataList1.DataSource = oDs; DataList1.DataBind(); } catch (Exception ex) { ex.ToString(); }
I recently uninstalled SQL Server due to connection issues I started having. I could start the DB and connect/edit tables in Ent Mgr etc, but all the sudden, none of my code could make DB connections.
So, after reinstalling now nothing works. I cannot even connect in Ent. Manager. I went to Administrative Tools->Services to make sure it was running, and SQLSERVER isn't even listed under services. What happened? Is there another step after installing SQL Server I missed to get the service up and going. Do I need to do something in ODBC connections?
Hello I am new to the ASP.NET project and using Microsoft ASP.Net Web Matrix. When I try to connect to an Access Database it is no problem, but do I try to set up an connection with a SQL or MSDE database there is a problem.
It can not connect with my SQL server and gives the error: Could not create new database.
What can be the problem. My MSSQL Server is running perfect.
i design a web site by vs.net 2003 and i connect to sql database its name rayan but when build my webfrom a error show this is system.data.sqlclient.sqlexception:login faild for user "rayanaspnet" please help me
A newbie needing some guidance. We have SQL running on our Windows 2003 server. When I connect via the Enterprise manager I have two instances of SQL running.
SRV01ACT7 (Windows NT) SRV01WEBAPP (Windows NT)
When I click on the ACT instance I get the following error: A connection could not be established to SRV01/ACT7
Reason: Login Failed for user xxxxadministrator. Please verify SQL Server is running and check your SQL Server registration properties.
I only get the message when I try to connect to the SRV01ACT. The connection to SRV01WEBAPP works fine.
I checked with SQL server manager and both instances are running and no one has reported any problems connecting to either one of them.
The way it acts, its as if SQL server has lost the ability to authorize a connection via the windows account. As if it has lost its associatoin to the administrator account. So while the instance still runs and is functional, I just can't connect to it and manage it.
I have connected via remote desktop from a WinXP machine and the server console. Both end up with the same error.
Can Someone give me step by step instructions on how to correct this?