المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Cannot connect into SQL Server using C#



C# Programming
04-23-2009, 09:13 PM
Bey guys,
i have a little problem, so if you can help me ill thank you...
i built a Sql server using Visual Stuido 2008 ( it created me a file name my_database.sdf ). now i am tring to connect to the sql server i have created,

i using the code below:
public void Connect()
{
this.han = new SqlConnection(@"Data Source=C:\Users\???\Documents\Visual Studio 2008\Projects\ADOtutorial\ADOtutorial\my_database.sdf;Persist Security Info=True;Application Name=ConnectDB");
Console.WriteLine(this.han.ConnectionString);
try
{
this.han.Open();
}
catch (NullReferenceException e)
{
Console.WriteLine(e);
}
catch (SqlException e)
{
Console.WriteLine(e);
}
}
this is a code in class, the class using this.han to make theconnection, the connection string i have copied from the connection strind i got from VS when i did motify connection -> advance. but for some resons i cant connect

the error i got:
Data Source=C:\Users\???\Documents\Visual Studio 2008\Projects\ADOtutorial\ADOtu
torial\my_database.sdf;Persist Security Info=True;Application Name=ConnectDB
System.Data.SqlClient.SqlException: ????? ????? ?????? ???? ?? ????? ??????? ???
?? ????? ????? ????? ?- SQL Server. ???? ?? ???? ?? ????? ????. ??? ?? ?? ?????
???? ??? SQL Server ????? ????? ??????? ???????. (provider: ????? ??? ?? SQL, e
rror: 26 - ????? ?????? ???/???? ?????)
?- System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exceptio
n, Boolean breakConnection)
?- System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateOb
ject stateObj)
?- System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInterna
lConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boo
lean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection
owningObject)
?- System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo
serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire
, SqlConnection owningObject)
?- System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String hos
t, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObjec
t, SqlConnectionString connectionOptions, Int64 timerStart)
?- System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnect
ion owningObject, SqlConnectionString connectionOptions, String newPassword, Boo
lean redirectedUserInstance)
?- System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIden
tity identity, SqlConnectionString connectionOptions, Object providerInfo, Strin
g newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
?- System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionO
ptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnectio
n owningConnection)
?- System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbCon
nection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
?- System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection ownin
gObject)
?- System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection
owningObject)
?- System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owni
ngObject)
?- System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection o
wningConnection)
?- System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection o
uterConnection, DbConnectionFactory connectionFactory)
?- System.Data.SqlClient.SqlConnection.Open()
?- ADOtutorial.Database_Driver.Connect() ?- C:\Users\???\Documents\Visual St
udio 2008\Projects\ADOtutorial\ADOtutorial\Database_Driver.cs:???? 46
Press any key to continue . . .
google translate for the hebrew there:

There was an error related to the network or specific error Lmo
According to the connection during the creation - SQL Server. Server not found or is not accessible. Verify that the instance name
Correct and that SQL Server is configured to allow remote connections. (provider: Web interface of SQL, e
rror: 26 - Error locating server / instance specified)


hope you can help me, thanks, Yahav http://www.barakasoft.com/script/Forums/Images/smiley_wink.gif

Gindi Bar Yahav - Web & Software defeloper.