connection with Sql Server

T

tolkien

Hi,i'm new in c# and i want to do this:
I have installed MS Sql server in my pc.
I 'm trying to create a winform which "reads" from a table in a
database and prints its data .
My biggest problem is :how the hell do i connect with the sql
server!!!

The name of the server is TURBOX
the name of the database is MYBUSINESS
the name of the table is SALGRADE

what i wrote is this:(I saw it in a tutorial )



string connectionString = "server=TURBOX; database=MYBUSINESS; uid=;
pwd=;";

SqlConnection conn = new SqlConnection(connectionString);

String commandString = "SELECT " + "GRADE,LOSAL,HISAL" + "FROM
SALGRADE";

SqlDataAdapter dataAdapter = new SqlDataAdapter(commandString, conn);




I didn't expect it to work of course :)
When i run this program i get an exception:

Login failed for user '(null)'. Reason: Not associated with a trusted
SQL Server connection.


I don't have a userid or a password
When i connect to the SQL server i use Windowns Authentication.

Any ideas?
Thanks anyway!!!!!!
 
M

Marc Gravell

For info, if you are using VS pro/team, the "server explorer" or other
data source tools can make light work of this. Curiously it isn't so
well supported in the express edition, but is possible (see previous
post).

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top