Showing posts with label username. Show all posts
Showing posts with label username. Show all posts

Thursday, March 8, 2012

connection to sql server

hi,
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.

Wednesday, March 7, 2012

Connection to an alias instead of a named server?

Is this doable?
The server name is TOPAZ
The alias name is topaz-alias
The username is somesqldb
The password is password
The following connection statement works:
Connection conn_topaz_byserver =
DriverManager.getConnection
("jdbc:microsoft:sqlserver://topaz;databasename=somesqldb"
,"somesqldb", "password");
The following connection statement fails:
Connection conn_topaz_byalias =
DriverManager.getConnection
("jdbc:microsoft:sqlserver://topaz-alias;databasename=somesqldb"
,"somesqldb", "password");
Galen Boyer
Hi Galen. The driver is trying to open a raw socket
to a machine named whatever you put in the URL
after the '//' and before the ';'. If you can
set up your DNI to find topaz from the alias,
then it will work.
Here's a program that opens a socket like the
typical type-4 driver will do, given the inputs
the URL and properties will supply. If you can
configure your OS dni info to get this program to
succeed opening the socket using the alias you want,
then the driver will too.
Joe Weinstein at BEA
import java.io.*;
import java.net.*;
public class isAnythingListeningOn
{
public static void main(String argv[])
throws Exception
{
if (argv.length != 2)
{
System.out.println("Usage: isAnythingListeningOn <host> <port>");
System.out.println("eg:\n% java isAnythingListeningOn myMachine 1433");
System.exit(0);
}
try
{
System.out.println("\nTrying to open a socket with host "
+ argv[0] + " and port " + argv[1] + " ...");
Socket socket = new Socket(argv[0],(new Integer(argv[1]).intValue()));
System.out.println("\nYes, there is, we got a socket.");
socket.close();
}
catch (Exception e)
{
System.out.println("We failed to open a socket. Here's why:\n");
e.printStackTrace();
System.out.println("\n(Either there is no machine named '" + argv[0]
+ "' or\nnothing is listening there on port "
+ argv[1] +")\n");
}
}
}
galenboyerdev@.hotpop.com wrote:

> Is this doable?
> The server name is TOPAZ
> The alias name is topaz-alias
> The username is somesqldb
> The password is password
> The following connection statement works:
> Connection conn_topaz_byserver =
> DriverManager.getConnection
> ("jdbc:microsoft:sqlserver://topaz;databasename=somesqldb"
> ,"somesqldb", "password");
>
> The following connection statement fails:
> Connection conn_topaz_byalias =
> DriverManager.getConnection
> ("jdbc:microsoft:sqlserver://topaz-alias;databasename=somesqldb"
> ,"somesqldb", "password");
>
|||Joe Weinstein <joeNOSPAM@.bea.com> writes:

> Hi Galen. The driver is trying to open a raw socket
> to a machine named whatever you put in the URL
> after the '//' and before the ';'. If you can
> set up your DNI to find topaz from the alias,
> then it will work.
[...]

> Socket socket = new Socket(argv[0],(new Integer(argv[1]).intValue()));
The following worked:
java.net.Socket socket = new java.net.Socket("topaz",1433);
The following failed:
java.net.Socket socket = new java.net.Socket("topaz-alias",1433);
So, the alias seems to be a "microsoft toolset only" feature.
Thanks.
Galen Boyer

Connection to a database

Hi,
I am trying to find out how to connect to a database, inside a stored
procedure...including identification (Username and passsword)?
I tried the CONNECT TO statement, but when I try to use it, I get the error:
[ODBC SQL Server Driver]Syntax Error or Access violation
I am using the connect to statemente this way:
Connect to {pc12.DB} User us.abc
DB= Databasename;
pc12= Servername;
us= Username;
abc= password
Can somebody tell me what is wrong with the way I use the connect statement
or tell me a better way to connect to databases?
ThanksCONNECT TO is IIRC only supported in Embedded SQL for C, not in stored
procedures and T-SQL.
If you are trying to connect to a database on the same server, you can just
access it by prefixing the tables etc with the database name and the owner
name in the form of:
SELECT some_column FROM other_database.dbo.some_table
If the database is on a different server, you can set up a linked server
(see BOL), and than add the server name to the select:
SELECT some_column FROM other_server.other_database.dbo.some_table
Jacco Schalkwijk
SQL Server MVP
"Albano Alves" <albano.alves@.vpconsulting.pt> wrote in message
news:eN6LxuKVFHA.2664@.TK2MSFTNGP15.phx.gbl...
> Hi,
> I am trying to find out how to connect to a database, inside a stored
> procedure...including identification (Username and passsword)?
> I tried the CONNECT TO statement, but when I try to use it, I get the
> error:
> [ODBC SQL Server Driver]Syntax Error or Access violation
> I am using the connect to statemente this way:
> Connect to {pc12.DB} User us.abc
> DB= Databasename;
> pc12= Servername;
> us= Username;
> abc= password
> Can somebody tell me what is wrong with the way I use the connect
> statement or tell me a better way to connect to databases?
> Thanks
>

Connection to a database

Hi,
I am trying to find out how to connect to a database, inside a stored
procedure...including identification (Username and passsword)?
I tried the CONNECT TO statement, but when I try to use it, I get the error:
[ODBC SQL Server Driver]Syntax Error or Access violation
I am using the connect to statemente this way:
Connect to {pc12.DB} User us.abc
DB= Databasename;
pc12= Servername;
us= Username;
abc= password
Can somebody tell me what is wrong with the way I use the connect statement
or tell me a better way to connect to databases?
Thanks
CONNECT TO is IIRC only supported in Embedded SQL for C, not in stored
procedures and T-SQL.
If you are trying to connect to a database on the same server, you can just
access it by prefixing the tables etc with the database name and the owner
name in the form of:
SELECT some_column FROM other_database.dbo.some_table
If the database is on a different server, you can set up a linked server
(see BOL), and than add the server name to the select:
SELECT some_column FROM other_server.other_database.dbo.some_table
Jacco Schalkwijk
SQL Server MVP
"Albano Alves" <albano.alves@.vpconsulting.pt> wrote in message
news:eN6LxuKVFHA.2664@.TK2MSFTNGP15.phx.gbl...
> Hi,
> I am trying to find out how to connect to a database, inside a stored
> procedure...including identification (Username and passsword)?
> I tried the CONNECT TO statement, but when I try to use it, I get the
> error:
> [ODBC SQL Server Driver]Syntax Error or Access violation
> I am using the connect to statemente this way:
> Connect to {pc12.DB} User us.abc
> DB= Databasename;
> pc12= Servername;
> us= Username;
> abc= password
> Can somebody tell me what is wrong with the way I use the connect
> statement or tell me a better way to connect to databases?
> Thanks
>