+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    Using SQL server in C#

     
    hi,
    I am new to .net and SQL stuff. I was reading tutorials on google and got the syntax for establishing an SQL connection but could understand it. So if someone could explain in a better way?

    SqlConnection myConnection = new SqlConnection("user id=username;" +
    "password=password;server=serverurl;" +
    "Trusted_Connection=yes;" +
    "database=databse; " +
    "connection timeout=30");


    i wanted to ask what should come in place of server url?
    and also, what should be written in place of databse??
    My database is named - "StuData" and is stored in path C:\myDataSrc.
    I am using SQL server 2008.

  2. #2
    Member
    Join Date
    Aug 2010
    Location
    delhi
    Posts
    30
    hi
    okk let me try

    here SqlConnection is a class and myConnection is its object.

    user id = it is used to specify the server login account

    password=it is used to specify the login password for the server login account

    server = it is the name of your server

    database=it is the name of the database that you are working on

    connection timeout = is the time in seconds to wait while a connection to the data source is attempted.

    for example in sql server 2005 if my server name is sqlserver098 and database name is HR and user id =sam and password is 1234
    then i will write the following query

    SqlConnection connection=new SqlConnection();
    and now gonna use the ConnectionString property of SqlConnection class
    connection.ConnectionString="Data Source=sqlserver098;Initial Catalog=HR; User ID=sa;password=1234"


    hope this helps

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. (SQL Server 2008) Exporting Databases to 'SQL INSERT' statements
    By gberz3 in forum Applications and Operating Systems
    Replies: 0
    Last Post: May 2nd, 2009, 11:46 PM
  2. Whats a MS SQL Server
    By J1mmy in forum Networking and Internet
    Replies: 4
    Last Post: November 29th, 2005, 12:38 PM
  3. Searching SQL Server
    By omalleytrading in forum Webmastering and Programming
    Replies: 18
    Last Post: July 7th, 2003, 09:22 PM
  4. VB Desktop Application Accessing SQL Server on Web Server
    By imd in forum Webmastering and Programming
    Replies: 1
    Last Post: October 24th, 2002, 01:21 PM
  5. VB Desktop Application Accessing SQL Server on Web Server
    By imd in forum Webmastering and Programming
    Replies: 0
    Last Post: October 24th, 2002, 05:44 AM

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Recommended Sites: ResellerRatings Store Reviews