PC Review


Reply
Thread Tools Rate Thread

connection with Sql Server

 
 
tolkien
Guest
Posts: n/a
 
      23rd Nov 2007
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 thisI 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!!!!!!













 
Reply With Quote
 
 
 
 
Marc Gravell
Guest
Posts: n/a
 
      23rd Nov 2007
Try adding ";Integrated Security=True" to the connection string.

For more info of all options:

http://msdn2.microsoft.com/en-us/lib...ionstring.aspx

Marc
 
Reply With Quote
 
Marc Gravell
Guest
Posts: n/a
 
      23rd Nov 2007
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
 
Reply With Quote
 
tolkien
Guest
Posts: n/a
 
      23rd Nov 2007
thanks man!!!
 
Reply With Quote
 
tolkien
Guest
Posts: n/a
 
      23rd Nov 2007
Dude ,it worked!!!!!!!!!!!!
thank you very very very much!!
 
Reply With Quote
 
Marc Gravell
Guest
Posts: n/a
 
      23rd Nov 2007
No problem; any other problems / questions, just post a new topic ;-p

Marc
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft VB .NET 0 8th Oct 2008 07:12 AM
An error has occurred while establishing a connection to the server.When connecting to SQL Server 2005, this failure may be caused by the factthat under the default settings SQL Server does not allow remote connections. mina Microsoft Dot NET 0 8th Oct 2008 07:11 AM
Change the local port of a server connection after connection isestablished Samik R. Microsoft Dot NET Framework 5 14th Dec 2006 02:29 AM
FTP loses connection when someone uses Remote Desktop Connection to server Chris Microsoft Windows 2000 Advanced Server 0 10th Mar 2004 06:07 PM
Remote Desktop Connection Over Cicso VPN Client connection to Windows 2000 Terminal Server David H. Windows XP Work Remotely 0 10th Mar 2004 09:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:42 AM.