Qbit75 0 Newbie Poster

Hi Im trying to run a .sql file from my c#.NET app using an SQLDMO object.Hi Im trying to run a .sql file from my c#.NET app using an SQLDMO object.
Im not too familiar with SQLDMO objects and am unsure about how to connect
to my database on our server.
i AM CONNECT TO SERVER BUT I NEED TO RUN MY SQL SCRIPT THROUGH IT HOW IT IS POSSIBLE
SQLDMO.sqlServer sqlServer;
sqlServer.CONNECT(SERVERNAME, UNAME,PASSWORD);

STRING SREQRY="USE DATABASE"+
"if not exists (select * from master.dbo.syslogins where loginname = N'TSLT_Test_user')"+
"BEGIN"+
" declare @logindb nvarchar(132), @loginlang nvarchar(132) select @logindb = N'TSLT_Test', @loginlang = N'us_english'"+
" if @logindb is null or not exists (select * from master.dbo.sysdatabases where name = @logindb)"+
" select @logindb = N'master'"+
" if @loginlang is null or (not exists (select * from master.dbo.syslanguages where name = @loginlang) and @loginlang <> N'us_english')"+
" select @loginlang = @@language"+
" exec sp_addlogin N'TSLT_Test_user', null, @logindb, @loginlang"+
"END"+
"GO"

How can i run this query in the DMO obj PLease HELP
any ideas please- Im really stuck on this concept

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.