Connecting Tech Pros Worldwide Forums | Help | Site Map

create sql server login (TSQL) ?

Sagaert Johan
Guest
 
Posts: n/a
#1: Nov 6 '08
Hi
How can i create an sql server login (sql 2005 express) ?
I have my TSQL code ready but how can i run it from c#?

How can i execute TSQL code from Csharp, or are there better ways using some
of the
Microsoft.SqlServer.Management classes to manage server logins?



Johan









Alberto Poblacion
Guest
 
Posts: n/a
#2: Nov 6 '08

re: create sql server login (TSQL) ?


"Sagaert Johan" <REMOVEsagaert_j@hotmail.comwrote in message
news:Od2tYY$PJHA.4504@TK2MSFTNGP02.phx.gbl...
Quote:
How can i create an sql server login (sql 2005 express) ?
I have my TSQL code ready but how can i run it from c#?
>
How can i execute TSQL code from Csharp, or are there better ways using
some of the
Microsoft.SqlServer.Management classes to manage server logins?
You can execute your TSQL code from C# in the same way as any DML
statement, using the ExecuteNonQuery method of a SqlCommand:

using System.Data.SqlClient;
....
string sql = "CREATE LOGIN test WITH PASSWORD='test'";
SqlCommand cmd = new SqlCommand(sql, myConnection);
cmd.ExecuteNonQuery();


Closed Thread


Similar C# / C Sharp bytes