.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

database connection problem

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :Windows Application

hi all

i am developing payroll system in c# winforms

i am having problems in database connection

i declared a connection string in app.config file

<add name="MyConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\UttamPayDB.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient" />

and i am using this connection string in my code

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString);

the problem is this connection string search the attached db file in my project's bin/debug folder

and When i use datagrid and bind it using datasource then this connectionstring search the attach db file in my project folder, not in bin/debug folder

what should i do???

plz help....


View Complete Post

More Related Resource Links

Database connection problem in ASP.NET

Hello,            I m having a database problem that I couldnt identify. The IIS loses connection to database once in 3 weeks.  Once  you restart the IIS everything is normal. Looks like IIS is fine because i can go to static pages. When I go to a page that requires database connection I get this error: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - Either the application has not called WSAStartup, or WSAStartup failed. A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)   Is this a connection string problem?. because without changing anything if I restart the webserver all is fine.  Is this a problem with application state?   It cant be at the sql server side as other applications on the machine work fine. There is something going on with IIS not sure what it is.   Any help would be appreiciated.   Thanks, Bharani      

Unable to make connection to database?


Hy guys. I try to connect my database for so long so i wrote two type of codes. Let's discuse first on.

I have database called PhoneDirectory.

It have only one table named Residents.

I have button wiht ID="Button1".

I want when i click this button to see all of my residents. 

I want to see the result in DetailsView and to be able to edin, delete and add new resident.

First try with SqlDataSource so i wrote this:

<asp:SqlDataSource ID="Resident Details" runat="server" ProviderName="System.Data.SqlClient" ConnectionStrings="<%$ ConnectionStrings:ThisIsTheConnection%>" 
              SelectCommand = "SELECT * FROM Resident "

Need Oracle Data Provider .CS File for Oracle 10g Database connection !



I need a 'Wrapper.cs' file which takes care of the Database connection ( Oracle 10g) where

i can just call the method with my SQL Query


Gridview1.DataSource = SampleWrapper.ExecuteDatatable("THE SQL QUERY");


Plz Post the link if there is any open source !    

Protect It: Safeguard Database Connection Strings and Other Sensitive Settings in Your Code


Protecting application secrets, such as database connection strings and passwords, requires careful consideration of a number of pertinent factors such as how sensitive the data is, who could gain access to it, how to balance security, performance, and maintainability, and so forth. This article explains the fundamentals of data protection and compares a variety of techniques that can be used to protect application settings. The author discusses what to avoid, such as hiding keys in source code and the use of Local Security Authority. In addition, he presents some effective solutions such as the Data Protection API.

Alek Davis

MSDN Magazine November 2003

Multiple Submit Connection Problem


Hello everyone,

I have an InfoPath form with two Submit Connections. One of them is a regular submit connection to a SharePoint Document Library. The other is a submit connection to the UpdateListItems web Service.

I have one button using rules that submits the forms fields to the Document Library. Some of those fields have data validation rules like entry must be four digits, and field cannot be blank.

The other submit button uses rules to submit an XML template to the UpdateListItems Template. My problem is that even though this second button does not have the first submit connection as an action, the form will still check all of the forms fields to see if they violate the validation rules before it will submit to the Web Service.

How do I tell InfoPath to ignore the validation rules when I only want to submit to the Web Service? I want the user to be able to enter data into the XML template fields and submit to the Web Service, even if some of the rest of the fields are blank. Right now if any of the other fields fail validation it prevents submittal to the web service even if the fields that failed validation are not being submitted to the web service.

Thanks for any advice that can be offered,
Bill Hurt

WSS 3.0 - problem with moving the database


My company wants to move a database included with WSS 3.0 installation to a *separate* server.
We want to have the database completely separated, on a different computer, on SQL Server 2005 installation.

Unfortunately, I'm not sure If the sharepoint is configured as a "Web Front End" or  "Stand-alone".
All I know, everything currently is on the same computer, and we can connect to the live database using the following path: \\.\pipe\MSSQL$MICROSOFT##SSEE\sql\query

The question is, how can we move the database to SQL Server 2005, on very different server, leaving the application untouched?

Quick summary, we currently have:

--- Server A: (WSS 3.0) + [windows internal database / SSEE (not sure!)] + DOMAIN X

and we want t

Excel Connection Manager Problem

I am building a package that has 2 tasks that need to use the same excel connection manager. I use a execute sql task to dynamically build a table from the headers of the excel sheet  ,then I use an excel source component to load the data from the sheet. However when I try to edit the excel source and switch the data access mode to a variable and select the variable(for the path), when I try to close the editor I get this message 'S:\myfolder'.  It is already opened exclusively by another user, or you need permission to view its data. I need this package to access the same folder each time because the files will be placed in that folder. This package also has a branch for loading a text file into sql server. It access the same folder but uses a flatfile connection manager It looks like permissions on the folder are correct

Context Connection problem in SQLCLR

I am using context connection in the sqlclr (and there are reasons to do so). While a datareader is under execution that uses the context connection, I need another database read passing one of values being read from the datareader. Since I cann't use the context connection for this second read (as context connection is already in use), how can I create a second connection to be used with this second read. I cannot create the hardcoded connections string for the second connection as the database is dynamically selected. The database is same as used by the context connection. I can use the server=localhost though, but cannot hardcode the database name as the database can be different in different sqlclr proc call. However the database is same as used by the context connection. (If I somehow get the database name from the context connection then I can use it to create another connection, but I am expecting an even better solution)   Any solution to this problem? Will be very thankful.

Problem with connection to sql server : A connection was successfully established with the server, b

Hi all, I am trying to connect sql server using windows authentication . I am getting the fallowing when I try to establish a connection to sql server A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) Can any one tell me how to resolve this problem..

SQL 2005 Database Problem

When trying open up a report from a customer database.  I recieved the following error: Please contact technical support with the following information:   Error ID: ERHIG030000340 Error message: There was a problem with the SQL or table when trying to open the display The table name is "taOrderHistory" The SQL is: Underlying problem: Column 'taOrderHistory.OrderHistoryID' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior) at System.Data.SqlClient.SqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) at System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) at RadWebNet.rwDataSupport.OpenData(String SQLIn, rwConnection ConnIn, OpenDSReturnType ReturnWhat, Int32 TimeOut, Object[] ParamsIn) in D:\Misc Projects\RadWeb\RadwebV4-7-1\rwData.v

Connection problem while connecting from client to server.

Hello, i am trying to connect sql server 2005 express using c#.net 3.5. my connection string is "Server=.\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_naren; Trusted_Connection=Yes;" this is working fine when i am connecting to sql server from the local machine. When i am trying to connect from someother machine to server it is giving error like A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) i added previliges in add new administrator on SQL Server 2005 Surface Area Configuration . and i made changes on SQL Server 2005 Surface Area Configuration  page, on Database Engine --> Remote Connections -->Local and remote connections --> Using both TCP/IP and named pipelines. still same error i am getting from client machine i am using connection string as "Server=MyServer\SQLExpress;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\DATA\db_naren.mdf;Database=db_nare; Trusted_Connection=Yes;" is there any thing i need to do to connect from client machine to server?please

Connection Problem with mysql and asp.net

i'm using this string to connect with mysql and asp.net but still agot the connection problem. the connection is not going to open............. i got the following error....... ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified please help me come from this problem "DRIVER={MySQL ODBC 3.51 Driver};DSN=sql4;SERVER=;DATABASE=myppw; UID=kraft; PASSWORD=myka; OPTION=3"

Problem with Movie Database Application

Hi Im following MVC tutorials on ASP.net website..I have a problem at Movies database application found in http://www.asp.net/mvc/tutorials/create-a-movie-database-application-in-15-minutes-with-asp-net-mvc-cs  Listing 3 - Views\Home\Index.aspx----------------------------------------------------------------------------------------------I dont understand where "Model" refer to in this code <% foreach (var item in Model) { %>  Also im confusing with accessing the database fields using var item Please explaine me what is happening in this code.<% foreach (var item in Model) { %> <tr> <td> <%= Html.ActionLink("Edit", "Edit", new { id=item.Id }) %> | <%= Html.ActionLink("Details", "Details", new { id=item.Id })%> Movie Database Application

Web Folder problem : This file cannot be saved to this location because there is no connection to th

When I check out a Word 2007 document from a list, I cannot save it back to the server.  I get:   This file cannot be saved to this location because there is no connection to the server.  Check your network connection and try again.   I am using a Virtual Machine (Virtual PC).  I have the Microsoft Loopback adapter installed.    The server has a static IP address and is a domain controller. I am able to access the web folder through Windows Explorer.   How do I set up Office, Sharepoint and Webdav so that I can check files out of sharepoint and save them back, on a virtual machine?

A connection could not be made to the report server - Problem deploying an SSRS report from Business

I’m having trouble with what seems to be a common issue for people, regarding deployment of an SSRS report from Business Intelligence Development Studio. Unfortunately none of the solution I have seen posted here (and elsewhere) have been able to help me so far.   Two of my collegaues can both deploy with no problem, and I am using exactly the same Target destinations as them (TargetDataSourceFolder, TargetReportFolder, TargetServerURL).   I have posted the error message below, which from my basic understaning would indicate, I think, a security issue (perhaps something local to my PC, or user account)   Has anyone experienced this particular issue who might be able to help?   Best wishes, Jamie TITLE: Microsoft Report Designer ------------------------------ A connection could not be made to the report server http://turpin-net.turpin-bg.local/Reportserver. ------------------------------ ADDITIONAL INFORMATION: Client found response content type of 'text/html; charset=utf-8', but expected 'text/xml'. The request failed with the error message: -- <HTML dir="ltr"> <HEAD><meta name="GENERATOR" content="Microsoft SharePoint" /><meta name="progid" content="SharePoint.WebPartPage.Document" /><meta HTTP-EQUIV="Content-Type" content="text/html; c

problem in connection string

i have problem in connection strin i host my siteand database is in DATA DIRECTORYmy site run successfully in offline but an error of connection string in online pls give me an example of string for onlinei use asp.net, C# and sqlserver 2005

problem rename sharepoint 2010 search service application admin database

Hi all, i have a problem that hopefully someone has an answer to.  i am not too familiar with sharepoint so please excuse my ignorance. we have sharepoint 2010 on a windows 2008r2 server.  everything seems to work fine.  but as you know, the default database names are horrendous.  i have managed to rename all of them, except for the "search service application" admin database. the default is: Search_Service_Application_DB_<guid> the other 2 databases (crawl and property) were renamed without a problem. we are following the article from technet on how to rename the search service admin db (http://technet.microsoft.com/en-nz/library/ff851878%28en-us%29.aspx).  it says to enter the following command: $searchapp | Set-SPEnterpriseSearchServiceApplication -DatabaseName "new database name" -DatabaseServer "dbserver" however, i get an error about identity being null.  no big deal, i add the -Identity switch and the name of my search service application.  but the real problem comes the error it throws:   Set-SPEnterpriseSearchServiceApplication : The requested database move was aborted as the associated search application is not paused. At line:1 char:54 + $searchapp | Set-SPEnterpriseSearchServiceApplication <<<<  -Identity "Search Service Application" -DatabaseName "ShareP
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend