Showing posts with label unable. Show all posts
Showing posts with label unable. Show all posts

Wednesday, March 28, 2012

How to connect using C#

Hi

I'm trying to connect to a MS SQL Server using ASP.NET / C#. I've
already got some VB code that works but I'm unable to translate it to
working C# code. Can anyone help me out?

Working VB code:

Dim Conn
Conn = CreateObject("ADODB.Connection")
Const ConnectionString = "DSN=dsn_name;database=database_name"
Conn.Open(ConnectionString, "user_name", "password")

Not working C# code:

string ConnectionString = "Initial Catalog=database_name;" +
"Data Source=dsn_name;" +
"User ID=user_name;" +
"Password=password;" +
"Integrated Security=SSPI;";

SqlConnection Connection = new SqlConnection(ConnectionString);
Connection.Open();
Connection.Close();Use exactly the same connection string form C# as for VB. If it works
in one, it'll work in the other.

Specifically, if you are using SSPI, you don't need to specify uid and
pw, and vice-versa.|||AHM (ingen@.spam.tak) writes:
> I'm trying to connect to a MS SQL Server using ASP.NET / C#. I've
> already got some VB code that works but I'm unable to translate it to
> working C# code. Can anyone help me out?

If you help us to help you. Don't just post:

> Not working C# code:
> string ConnectionString = "Initial Catalog=database_name;" +
> "Data Source=dsn_name;" +
> "User ID=user_name;" +
> "Password=password;" +
> "Integrated Security=SSPI;";
> SqlConnection Connection = new SqlConnection(ConnectionString);
> Connection.Open();
> Connection.Close();

Tell us in what way it is not working. Do you get an error message?
Do you get unexpected results? Does the light go out?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||> string ConnectionString = "Initial Catalog=database_name;" +
> "Data Source=dsn_name;" +
> "User ID=user_name;" +
> "Password=password;" +
> "Integrated Security=SSPI;";

Note the change to 'Data Source' in the example below as well as the removal
of the unnecessary User ID and Password parameters:

string ConnectionString = "Initial Catalog=database_name;" +
"Data Source=database_server_name;" +
"Integrated Security=SSPI;";

--
Hope this helps.

Dan Guzman
SQL Server MVP

"AHM" <ingen@.spam.tak> wrote in message
news:MPG.1cb65eb0b33ffb61989705@.news.inet.tele.dk. ..
> Hi
> I'm trying to connect to a MS SQL Server using ASP.NET / C#. I've
> already got some VB code that works but I'm unable to translate it to
> working C# code. Can anyone help me out?
> Working VB code:
> Dim Conn
> Conn = CreateObject("ADODB.Connection")
> Const ConnectionString = "DSN=dsn_name;database=database_name"
> Conn.Open(ConnectionString, "user_name", "password")
> Not working C# code:
> string ConnectionString = "Initial Catalog=database_name;" +
> "Data Source=dsn_name;" +
> "User ID=user_name;" +
> "Password=password;" +
> "Integrated Security=SSPI;";
> SqlConnection Connection = new SqlConnection(ConnectionString);
> Connection.Open();
> Connection.Close();

Friday, March 23, 2012

how to connect sql server to oracle

ha
i am facing the problem that
i am unable to connect sql server to oracle
i have sqlserver in my system and oracle server is in remote
i want to access that database with using DTS
so that ,mmy memory will bw save
could any one please help for this
please yaar i am waitinf fro urs reply
Configure it as a linked server. To create linked server , open
EM->Security->Linked Server.
vinu
"dev" <dev@.discussions.microsoft.com> wrote in message
news:50B38365-9030-4810-9753-D58C5FAD591E@.microsoft.com...
> ha
> i am facing the problem that
> i am unable to connect sql server to oracle
> i have sqlserver in my system and oracle server is in remote
> i want to access that database with using DTS
> so that ,mmy memory will bw save
> could any one please help for this
>
> please yaar i am waitinf fro urs reply
>
|||hi
vinu
i did that
EM->Security->Linked Server.
but when ever i am trying to acess the table it gives a message that
ERROR 7399:OLEDB provider 'MSDAORA' reported an error
could u please clarify about this
"vinu" wrote:

> Configure it as a linked server. To create linked server , open
> EM->Security->Linked Server.
> vinu
>
> "dev" <dev@.discussions.microsoft.com> wrote in message
> news:50B38365-9030-4810-9753-D58C5FAD591E@.microsoft.com...
>
>
|||This might be helpful
http://support.microsoft.com/kb/280106
vinu
"dev" <dev@.discussions.microsoft.com> wrote in message
news:4A97A14E-04C8-4460-9688-2A4FAD4697FB@.microsoft.com...[vbcol=seagreen]
> hi
> vinu
> i did that
> EM->Security->Linked Server.
> but when ever i am trying to acess the table it gives a message that
> ERROR 7399:OLEDB provider 'MSDAORA' reported an error
> could u please clarify about this
>
> "vinu" wrote:
|||hi vinu
let me try this it will take some time it has some work with registry
fro that it s late
thanks fro giviing this suggestion
if nothing i will get back to you
thanks yaar
"vt" wrote:

> This might be helpful
> http://support.microsoft.com/kb/280106
>
> vinu
>
> "dev" <dev@.discussions.microsoft.com> wrote in message
> news:4A97A14E-04C8-4460-9688-2A4FAD4697FB@.microsoft.com...
>
>
|||Can you connect using the native Oracle tools? net Configuration Assistant
provides a means of testing the connection, and SQL+ will also do the same.
This is the first step and the most often missed step - to check that you
have a valid TNS entry and the firewall is correctly configured.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com .
sql