Results 1 to 10 of 10

Thread: sqlexception...

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599

    sqlexception...

    an unhandled exception of type System.Data.SqlClient.SqlException occured in System.Data.dll

    Additional information : System Error

    and the line of code highlighted is :

    VB Code:
    1. ... blablabla connectionstring
    2. conn.open
    3.  
    4.  
    5. [B]SqlConnection sc = new SqlConnection ("Data Source=myDB;Initial Catalog=pubs;username=guest;password=",conn)
    6. [/B]
    Thank You

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    What kind of database are you connecting to ? Is it local or on another PC ?

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599
    Pirate ,

    It is on local machine. It is SQL Server 2000 Database.... called myDB......


    is my syntax wrong or something else?
    DAta Source is refer to database NAme right?
    Thank You

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    DataSource is the SQL Server/IP (even if it's local) that the connection will be connecting to . So you have to specify what's your SQL Server name and then \your database name (if I still remember correctly) .

  5. #5
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Ok , I got it now .

    [Data Source]
    If local then it's like this :
    Data Source=local;

    if on remote PC , it's this one :
    Data Source=Data Source=xxx.xxx.xxx.xxx,1433;"
    xxx is the IP number and 1433 is the default port for SQL Server .


    [Initial Catalog] = is the SQL Database Name .



    quoted from this link .
    http://www.able-consulting.com/dotne..._Providers.htm

    Hope that helps .

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599
    Hi Pirate,

    SqlConnection sc = new SqlConnection ("Data Source=(local);Initial Catalog=pubs;username=tester;password=tester")
    sc.open()

    my SQL Server Instance Name = SGS-Monster\SQL2000K
    my Username for login = tester
    my password = tester
    already assign the user to DATABASE = pubs

    and that is the only instance that i start and also the only instance that already been registered.


    i really can;t figure out why it just wont work... "Wasting my weeks of time trying to find out just to connect?" --- i am really ...geexzzz

    Can anyone just contruct the complete connectionstring by using the information above???
    Thank You

  7. #7
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Did you try it with Try ...catch block to get more specific error info ?

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599
    i haven't try "Try...Catch" .... but is it necessaryt ///... i am too new to .net

    i will try it out
    Thank You

  9. #9
    Junior Member
    Join Date
    Feb 2004
    Posts
    29

    try this

    i had the same problem and wasted abt five day on just how to connect..but eventualy solved it with the help of pirate...well anyways...my code looks different from yours..maybe if u havent solved it u can try it this way..


    Code:
    using System.Data.SqlClient;
    ...
    try
    {
    SqlConnection oSQLConn = new SqlConnection();
    
    oSQLConn.ConnectionString = ("Integrated Security=SSPI"; "database = your database"; "server = your server" ; "connection timeout = 30");
    
    oSQLConn.Open();
    
    MessageBox.Show("Connected!");
    }
    
    catch (Exception e)
    {
       MessageBox.Show(e.ToString());
    }

    integrated security means u dont have to code anythin abt your user name and password...more security..

    well this is all...try it and see if it works.
    Arvinder Gill

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Feb 2003
    Posts
    599
    Wow ,

    Asgill you are luckier than i... as i had spent more than 5 days for figuring out just how to connect...

    anyway, thanks and i will try your way instead


    i will let you know if it works
    Thank You

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width