Click here to Skip to main content
15,915,328 members
Home / Discussions / C#
   

C#

 
GeneralRe: Homography Question Pin
User 66583-Dec-08 0:16
User 66583-Dec-08 0:16 
GeneralRe: Homography Question Pin
VincentOng3-Dec-08 0:34
VincentOng3-Dec-08 0:34 
GeneralRe: Homography Question Pin
User 66583-Dec-08 0:56
User 66583-Dec-08 0:56 
GeneralRe: Homography Question Pin
Luc Pattyn3-Dec-08 1:06
sitebuilderLuc Pattyn3-Dec-08 1:06 
GeneralRe: Homography Question Pin
VincentOng3-Dec-08 1:08
VincentOng3-Dec-08 1:08 
GeneralRe: Homography Question Pin
Luc Pattyn3-Dec-08 1:30
sitebuilderLuc Pattyn3-Dec-08 1:30 
GeneralRe: Homography Question Pin
Christian Graus4-Dec-08 8:17
protectorChristian Graus4-Dec-08 8:17 
QuestionConnecting with remote server Pin
SelvaSR2-Dec-08 22:52
SelvaSR2-Dec-08 22:52 
i m trying to configure db in remote server through C# , locally it is configuring but in Remote Server db is is not creating. Following is the code

public bool createDB(object sServerName, String sDBName,object sAdminUname,object sAdminPwd)
{
object objServerName;
objServerName = sServerName;

SQLDMO.SQLServer gSQLServerDMO = new SQLDMO.SQLServer();
SQLDMO.Database nDatabase = new SQLDMO.Database();
SQLDMO.DBFile nDBFileData = new SQLDMO.DBFile();
SQLDMO.LogFile nLogFile = new SQLDMO.LogFile();

try
{
gSQLServerDMO.Connect(objServerName, sAdminUname, sAdminPwd);
nDatabase.Name = sDBName;
nDBFileData.Name = sDBName;
nDBFileData.PhysicalName = gSQLServerDMO.Registry.SQLDataRoot + "\\DATA\\" + sDBName + "_Data.mdf";
nDBFileData.PrimaryFile = true;
nDBFileData.Size = 2;
nDBFileData.FileGrowthType = SQLDMO.SQLDMO_GROWTH_TYPE.SQLDMOGrowth_MB;
nDBFileData.FileGrowth = 1;

//Adding DBFile object
nDatabase.FileGroups.Item("PRIMARY").DBFiles.Add(nDBFileData);

nLogFile.Name = sDBName + "_Log";
nLogFile.PhysicalName = gSQLServerDMO.Registry.SQLDataRoot + "\\DATA\\" + sDBName + "_Log.ldf";
nLogFile.Size = 2;
nDatabase.TransactionLog.LogFiles.Add(nLogFile);

gSQLServerDMO.Databases.Add(nDatabase);
return true;
}
catch (Exception sqlDBException)
{
String errSqlDBexception = sqlDBException.Message;
return false;
}
finally
{
gSQLServerDMO.DisConnect();
}
}

//Section for creating the database login and user in the above created Database.//

public bool Createdatabaselogin(String sDataSource, string databsename, String sScriptName, String sUserId, String sPwd, string loginName, string loginpass)
{
try
{
string sqlConnectionString = "Data Source=" + sDataSource + ";Initial Catalog=" + databsename + ";USER ID=" + sUserId + "; PWD=" + sPwd + ";Persist Security Info=True";
SqlConnection conn = new SqlConnection(sqlConnectionString);
Server server = new Server(new ServerConnection(conn));
string sqlquerylogin = "EXEC sp_addlogin '" + loginName + "','" + loginpass + "'";
string sqlqueryuser = "EXEC sp_adduser '" + loginName + "','" + loginName + "','db_owner'";
if (!server.Logins.Contains(loginName))
{
server.ConnectionContext.ExecuteNonQuery(sqlquerylogin);
}

server.ConnectionContext.ExecuteNonQuery(sqlqueryuser);

return true;
}
catch (Exception ex)
{
String error_str = ex.ToString();
return false;
}
}



What is wrong in this , can anyone suggest some idea?
Questionconsole application current path Pin
l.laxmikant2-Dec-08 22:18
l.laxmikant2-Dec-08 22:18 
AnswerRe: console application current path Pin
leppie2-Dec-08 22:37
leppie2-Dec-08 22:37 
AnswerRe: console application current path Pin
Simon P Stevens2-Dec-08 22:39
Simon P Stevens2-Dec-08 22:39 
QuestionProblem In Spliting Query Pin
ais072-Dec-08 21:56
ais072-Dec-08 21:56 
AnswerRe: Problem In Spliting Query Pin
Simon P Stevens2-Dec-08 22:10
Simon P Stevens2-Dec-08 22:10 
GeneralRe: Problem In Spliting Query Pin
ais072-Dec-08 22:28
ais072-Dec-08 22:28 
GeneralRe: Problem In Spliting Query Pin
Simon P Stevens2-Dec-08 22:37
Simon P Stevens2-Dec-08 22:37 
AnswerRe: Problem In Spliting Query PinPopular
Christian Graus2-Dec-08 22:19
protectorChristian Graus2-Dec-08 22:19 
Questiononline forum Pin
kavitaBC2-Dec-08 21:03
kavitaBC2-Dec-08 21:03 
AnswerRe: online forum Pin
Simon P Stevens2-Dec-08 22:06
Simon P Stevens2-Dec-08 22:06 
QuestionSQL Pin
ellllllllie2-Dec-08 20:59
ellllllllie2-Dec-08 20:59 
AnswerRe: SQL Pin
Simon P Stevens2-Dec-08 21:59
Simon P Stevens2-Dec-08 21:59 
AnswerRe: SQL Pin
Christian Graus2-Dec-08 22:16
protectorChristian Graus2-Dec-08 22:16 
Questionself ordering list Pin
rgerla2-Dec-08 20:42
rgerla2-Dec-08 20:42 
AnswerRe: self ordering list Pin
Mycroft Holmes2-Dec-08 20:52
professionalMycroft Holmes2-Dec-08 20:52 
GeneralRe: self ordering list Pin
rgerla3-Dec-08 0:32
rgerla3-Dec-08 0:32 
AnswerRe: self ordering list Pin
HosamAly2-Dec-08 21:02
HosamAly2-Dec-08 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.