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. Transfer an SQL database?

Transfer an SQL database?

Scheduled Pinned Locked Moved C#
questiondatabasesql-serverhelpsysadmin
2 Posts 2 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.
  • C Offline
    C Offline
    cemlouis
    wrote on last edited by
    #1

    Hi, Q1: How can I transfer an SQL database manually? I have a database which is named mydb, I looked at the harddrive and found it on "C:\Program Files\Microsoft SQL Server\MSSQL\Data" there is 2 file one of them is mydb.mdf and the lof file of that. I copied these on another machine on the same path but couldn't make it to work??? Q2: I used the below code to EMPTY a table which is named people but it is not working???: SqlConnection mySqlConnection4 = new SqlConnection("Initial Catalog=mydb;Data Source=" + comboBox1.SelectedItem.ToString() + ";Integrated Security=SSPI;"); mySqlConnection4.Open(); SqlCommand mySqlCommand4 = mySqlConnection4.CreateCommand(); SqlTransaction myTrans; myTrans = mySqlConnection4.BeginTransaction(IsolationLevel.ReadCommitted,"SampleTransaction"); mySqlCommand4.Connection = mySqlConnection4; mySqlCommand4.Transaction = myTrans; mySqlCommand4.CommandText = "EMPTY people" ; //mySqlCommand4.ExecuteNonQuery(); myTrans.Commit(); mySqlConnection4.Close(); Anyway What is the problem??? Any help would be greatly appreciated... Cem Louis

    C 1 Reply Last reply
    0
    • C cemlouis

      Hi, Q1: How can I transfer an SQL database manually? I have a database which is named mydb, I looked at the harddrive and found it on "C:\Program Files\Microsoft SQL Server\MSSQL\Data" there is 2 file one of them is mydb.mdf and the lof file of that. I copied these on another machine on the same path but couldn't make it to work??? Q2: I used the below code to EMPTY a table which is named people but it is not working???: SqlConnection mySqlConnection4 = new SqlConnection("Initial Catalog=mydb;Data Source=" + comboBox1.SelectedItem.ToString() + ";Integrated Security=SSPI;"); mySqlConnection4.Open(); SqlCommand mySqlCommand4 = mySqlConnection4.CreateCommand(); SqlTransaction myTrans; myTrans = mySqlConnection4.BeginTransaction(IsolationLevel.ReadCommitted,"SampleTransaction"); mySqlCommand4.Connection = mySqlConnection4; mySqlCommand4.Transaction = myTrans; mySqlCommand4.CommandText = "EMPTY people" ; //mySqlCommand4.ExecuteNonQuery(); myTrans.Commit(); mySqlConnection4.Close(); Anyway What is the problem??? Any help would be greatly appreciated... Cem Louis

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      Q1: What was the error message when you tried to attach it to the SQL Server on the other machine? Q2: At a quick glance the line with the ExecuteNonQuery() is commented out. Also, I cannot find the EMPTY keywork in the Transact-SQL reference. Are you sure you are using the right command? I would have used DELETE.


      Do you want to know more? Not getting the response you want from a question asked in an online forum: How to Ask Questions the Smart Way!

      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