Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Connecting with remote server

Connecting with remote server

Scheduled Pinned Locked Moved C#
databasecsharpsysadminwindows-adminsecurity
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SelvaSR
    wrote on last edited by
    #1

    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 ser

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups