Cannot connect into SQL Server using C#
-
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(SqlConn -
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(SqlConn -
.sdf files are SQL CE databases, not SQL Server. You have created an "embedded" database. The database that you wanted (SQL Server) has the file-extension ".mdf". What did you use to create the database?
I are troll :)
thanks for the replay, umm i didnt know that this is not a SQL Server... i open new Console APP (to check this, acualy i am building a program to my website in WIN but now i need to learn it first.. i done it before with MYSQL but...) so~, i clicked on Add new item (in the sulution explorer) and them local database connection. umm... and them i saw the database in the database explorer and i could edit tables, add tables etc... if its not mysql, can you explin me where i can find the way to connect to that type of sql server?
Gindi Bar Yahav - Web & Software defeloper.
-
thanks for the replay, umm i didnt know that this is not a SQL Server... i open new Console APP (to check this, acualy i am building a program to my website in WIN but now i need to learn it first.. i done it before with MYSQL but...) so~, i clicked on Add new item (in the sulution explorer) and them local database connection. umm... and them i saw the database in the database explorer and i could edit tables, add tables etc... if its not mysql, can you explin me where i can find the way to connect to that type of sql server?
Gindi Bar Yahav - Web & Software defeloper.
Do you want: * SQL Server (Serves lots of people at once) * SQL CE (Embedded database) * MySQL (...) ? The
SQLConnection
is used for SQL Server, not MySQL. SQL Server might be installed by the VS2008 setup, MySQL is a separate download. Downloads be here[^], tutorials on SQL Server are here[^].I are troll :)
-
Do you want: * SQL Server (Serves lots of people at once) * SQL CE (Embedded database) * MySQL (...) ? The
SQLConnection
is used for SQL Server, not MySQL. SQL Server might be installed by the VS2008 setup, MySQL is a separate download. Downloads be here[^], tutorials on SQL Server are here[^].I are troll :)
thanks you very moch for your help, what i am looking for is a software database so i dont really i need very big database, but ill try to work with SQL server to learn it... the last qustion if you can help me is if you know where i can find database hosting
Gindi Bar Yahav - Web & Software defeloper.
-
thanks you very moch for your help, what i am looking for is a software database so i dont really i need very big database, but ill try to work with SQL server to learn it... the last qustion if you can help me is if you know where i can find database hosting
Gindi Bar Yahav - Web & Software defeloper.
Gindi Bar Yahav wrote:
where i can find database hosting
I'd like to recommend ASP Spider[^]. It's the ideal place to try out new ASP.NET/SQL projects, since it is free.
I are troll :)
-
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(SqlConn -
Hi, add another \ to every \ you have in the connectionstring. Hope this one can help Thanks
i have tried it before, it dosent do any change, becuse i added @ before the connection string.
Gindi Bar Yahav - Web & Software defeloper.