|
-
Feb 2nd, 2004, 10:28 PM
#1
Thread Starter
Fanatic Member
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:
... blablabla connectionstring
conn.open
[B]SqlConnection sc = new SqlConnection ("Data Source=myDB;Initial Catalog=pubs;username=guest;password=",conn)
[/B]
-
Feb 4th, 2004, 05:16 AM
#2
Sleep mode
What kind of database are you connecting to ? Is it local or on another PC ?
-
Feb 5th, 2004, 06:09 AM
#3
Thread Starter
Fanatic Member
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?
-
Feb 5th, 2004, 06:25 AM
#4
Sleep mode
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) .
-
Feb 5th, 2004, 06:32 AM
#5
Sleep mode
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 .
-
Feb 8th, 2004, 08:24 PM
#6
Thread Starter
Fanatic Member
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???
-
Feb 8th, 2004, 10:43 PM
#7
Sleep mode
Did you try it with Try ...catch block to get more specific error info ?
-
Feb 9th, 2004, 11:48 PM
#8
Thread Starter
Fanatic Member
i haven't try "Try...Catch" .... but is it necessaryt ///... i am too new to .net
i will try it out
-
Feb 10th, 2004, 01:43 AM
#9
Junior Member
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.
-
Feb 10th, 2004, 10:55 PM
#10
Thread Starter
Fanatic Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|