in my server explorer i add a connection;
server name is cerebrum,username is ga, no password and database in the server is dal.
i tested the connection and it is successful. i am now able to browse the table in my server explorer. from my server explorer the i dragged the just data connection:cerebrum.dal.dbo in my design form and it created SqlConnection1 which contain my connection. properties of my SqlConnection1:
Name: SqlConnection1
ConnectionString: workstation id=SOLARIS;packet size=4096;user id=ga;data source=cerebrum;persist security info=False;initial catalog=dal
ConnectionTime: 15
Database: dal
DataSource: cerebrum
Modifiers: Protected
PacketSize: 4096
WorkstationId: Solaris
in my page load i added this code:
SqlConnection1.Open();
if (SqlConnection1.State == ConnectionState.Open)
{
Label1.Text = "SQL Connection is open";
}
else
{
Label1.Text = "SQL Connection is closed";
}
it gave me the error:
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.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
Line 51: SqlConnection1.Open();
Line 52: if (SqlConnection1.State == ConnectionState.Open)
i don't know what's wrong with it. i really need your help.
This error means that the web server cannot open a connection to cerebrum SQL Server. It could mean that you cannot connect over TCP-IP to the computer cerebrum from your web server. So go to web server and try to ping cerebrum, see if this is successfull.
Try modifying the datasource to give the driver more clues about where your database server is. For example, replace cerebrum with the IP address of cerebrum, try variations like below:
datasource=123.123.123.123
datasource=123.123.123.123,1433
datasource=tcp:cerebrum,1433
With .NET you need to use tcp-ip, verify that your SQL Server is using tcp-ip protocol by looking that the SQL Server errorlog.