Hi all,
I moved from .php, mysql, and Apache to Ms C# 2005 and Ms Server 2005. I want to connect my program C# to a Ms database, just like .php connect to mysql. How do I go about that, what do I need. I had installed "Ms visual C# 2005 express edition" and also "Microsoft SQL Server 2005" on my computer. What else do I need thanks
Jason

New to MsC#2005 and Ms Server 2005, need help!!
ploaiza
hi,
there is a nice tutorial but will take some times from you, along with the artical you will do it
http://msdn.microsoft.com/vstudio/express/sql/learning/default.aspx
hope this helps
fandango20
Sanjay12345
Hi,
I try to connect to my SQLEXPRESS server 2005, and got this errors:
Attempting connection
[Microsoft][SQL Native Client]VIA Provider: The specified module could not be found.
[Microsoft][SQL Native Client]Login timeout expired
[Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
How do I set my SQL Server to accept remote connections, any ideas
Thanks
Jason
Kenneth Mitchell
I have another question after read the article. I have "Ms SQL Server Management Studio Express" connect to my SQL Server 2005 successully and I also created a database in the Management Studio. Then I try to follow along with the article to connect to the database but not successful. Here is what I got from the article.
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
namespace SQL{
class Program
{
static void Main(string[] args)
{
SqlConnection myConnection = new SqlConnection("user id=Administrator;" +
"password=password;server=localhost;" +
"Trusted_Connection=yes;" +
"database=database; " +
"connection timeout=30");
try
{
myConnection.Open();
}
catch(Exception e)
{
Console.WriteLine(e.ToString());
}
SqlCommand myCommand = new SqlCommand("INSERT INTO table (Column1, Column2) " + "Values ('string', 1)", myConnection);
myCommand.BeginExecuteNonQuery();
}
}
}
//--------------------------------Errors I got when run the program----------------------------------
System.Data.SqlClient.SqlException: An error has occurred while establishing a connection
to the server. When connecting to SQL Server 2005, this failure may be caused by the fact
that under the default settings SQL Server does not allow remote connections. (provider:
Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean
breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateO
bj)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner, Boolean& failov
erDemandDone, String host, String failoverPartner, String protocol, SqlInternalConnectionT
ds connHandler, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integ
ratedSecurity, SqlConnection owningObject, Boolean aliasLookup)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningO
bject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserIn
stance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identi
ty, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlCon
nection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions opti
ons, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection own
ingConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObjec
t)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnec
tion)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnect
ion, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at SQL.Program.Main(String[] args) in C:\Documents and Settings\Administrator\Local Set
tings\Application Data\Temporary Projects\SQL\Program.cs:line 20
//---------------------------------------------------------------------------------------------------------
What else do I need to connect to my newly created database from which I created in the Management Studio.
Thanks
Jason
lizajane999
You're the man, thanks for your help!!
Jason