Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Opening a connection to Sql Server using C#
Message
 
À
02/08/2001 02:09:17
Mahabeer B.
Wipro Technologies
Hyderabad, Inde
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00538714
Message ID:
00538850
Vues:
7
>Hi,
>
>I am trying to connect to a local SQL Server on the Network using the
>following code in Beta2(System.Data.SqlClient).
>
>#####
>
> string sConn = "User ID=sa;Pwd=;Database=lib;Server=rukku;Integrated
>Security=false";
>
> string sCommand = "SELECT max(book_id)from book_details";
> SqlCommand myCommand = new SqlCommand(sCommand);
> myCommand.Connection = new SqlConnection(sConn);
> myCommand.Connection.Open();
>
>#####
>
>But I am getting a SecurityException.
>
>Do I need to setup special permission on the SQL Server before executing
>these statements, because I am getting some Permission problems.The error is occurring at the Open() statement. Can anyone help !
>
>
>Regds,
>Mahabeer

This has been known to be fun! Not really, but here are a few ideas.


Since you are using ODBC here is some code I use for that purpose:
strConn = "Driver={SQL SERVER};SERVER=T22VSQ02;DATABASE=QMDS;UID=QMDSWebUser;PWD=WebUser;"

If SQL Server is on the same machine as is being used for development things normally work well. When you run the data from a different server things do get interesting.

If you have not done so try the following:
1. Right Click on the database ICON from the Enterprise Manager in SQL Server. Go to Permission and define public roles as required
3. Be sure you are set up with your user security with a public entry.

Tom
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform