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


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

dot net sql connection

Posted By: Kemal AL GAZZAH     Posted Date: September 08, 2011    Points:5   Category :Sql Server
I have a dot net 2.0 application connecting to a sql server data base
The string connection is stored in web.config.

The application connects without any problem to the sql server data base when both the IIS server and the data base server are in the same machine

It also works fine in debugging mode using Visual Studio 2008 when IIS and sql are in the same or in different machines

BUT THE ONLY ISSUE is that it fails to connect to the sql server if IIS and sql server are in two different machines which are in the same LAN , I can ping to the DB server from the IIS server and VICE VERSA
Any idea to fix this issue ?

Responses
Author: Narayanan             
Posted Date: September 08, 2011     Points: 20   

hi,
I am not that much of experience in this issue.
please check your sql server name or database. or
create a .ini file in your project.On that .ini file give a server name, database name ,username and password .
To call that ini file in your project and paste that .ini file in your debug folder and use debug folder to another system and run the application.
Regards,
Lakshmi Narayanan.S

Regards, Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
Author: Sasi Prabhu             
Posted Date: September 09, 2011     Points: 20   

Try :

Check the Connection String in Web.Config..

Thanks & Regards,
Sasi Prabhu.
Author: sriram             
Posted Date: October 27, 2011     Points: 20   


using System.Data.SqlClient;
using System.Data;

Web.Config:
----------

<appSettings>

<add key="DSV" value="server=Servername;UID=username;PWD=password;DataBase=Databasename">

</appsettings>

Form1.aspx.cs:

string str=ConfigurationSettings.Appsettings["DSV"].tostring();
sqlconnection con=new sqlconnection(str);
string myQuery="select * from employee";
sqldataadapter adp=new sqldataadapter(myquery,con);
dataset ds=new dataset()
adp.fill(ds);
Gridview.Datasource=ds;
Gridview.DataBind();

Hope this wll Help..
Let me know any Queries..


Regards
Sriram.R



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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