當前位置:首頁 » 編程語言 » 如何把資料庫文件傳到sql上
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

如何把資料庫文件傳到sql上

發布時間: 2023-02-22 22:51:55

❶ 怎麼把資料庫表格中數據導出為sql文件

  1. 首先進去資料庫,找到你要存儲的表格,右鍵點擊表名,選擇轉儲sql文件;

  2. 選擇結構和數據,這樣子就都存進去了;

  3. 然後在彈出框中選擇你要存儲的位置;

  4. 點擊保存後,點擊開始;

  5. 檢查有沒有錯誤數據,沒有點擊完成;有錯誤也要點擊完成,然後去表格查找錯誤的信息;

  6. 去存儲路徑找你的文件,看是否保存成功。

❷ 如何導出mysql資料庫到sql文件

方法如下:

1.在本地建一個與資料庫同名的資料庫。

2.選擇navicat中連接伺服器的資料庫,在菜單欄選擇工具-->數據傳輸。

拓展資料:

導出資料庫用mysqlmp命令(注意mysql的安裝路徑,即此命令的路徑):

導出數據和表結構:mysqlmp -u用戶名 -p密碼 資料庫名 > 數據名.sql#/usr/local/mysql/bin/ mysqlmp -uroot -p abc > abc.sql,敲回車後會提示輸入密碼。

❸ c怎麼把數據存到sql

1. C#中怎麼把數據保存到ACCESS資料庫
Sqlmand是操作sql資料庫的,Access用OleDbmand首先定義一個鏈接對象OleDbConnection conn = new OleDbConnection("[資料庫連接字元串]");conn.Open(); 打開資料庫連接OleDbmand cmd = new OleDbmand("[Insert/Update/Delte語句]", conn);cmd.ExecuteNonQuery(); 執行操作,如果是查詢則不是用這個方法 最後別忘記關閉資料庫連接和釋放對象。
2. C# 如何將 圖片直接存入SQL資料庫中
把文件轉成二進制流出入資料庫

private void button2_Click(object sender, EventArgs e)

{

FileStream fs = new FileStream(textBox1.Text, FileMode.Open);

BinaryReader br = new BinaryReader(fs);

Byte[] byData = br.ReadBytes((int)fs.Length);

fs.Close();

string conn = "server=.;database=testDB;Uid=sa;Pwd=sa ";

SqlConnection myconn = new SqlConnection(conn);

myconn.Open();

string str = "insert into pro_table (pro_name,pro_file) values('測試文件',@file)";

Sqlmand mym = new Sqlmand(str, myconn);

mym.Parameters.Add("@file", SqlDbType.Binary, byData.Length);

mym.Parameters["@file"].Value = byData;

mym.ExecuteNonQuery();

myconn.Close();

}

從資料庫中把二進制流讀出寫入還原成文件

private void button4_Click(object sender, EventArgs e)

{

string conn = "server=.;database=testDB;Uid=sa;Pwd=sa ";

string str = "select pro_file from pro_table where pro_name='測試文件' ";

SqlConnection myconn = new SqlConnection(conn);

SqlDataAdapter sda = new SqlDataAdapter(str, conn);

DataSet myds = new DataSet();

myconn.Open();

sda.Fill(myds);

myconn.Close();

Byte[] Files = (Byte[])myds.Tables[0].Rows[0]["pro_file"];

BinaryWriter bw = new BinaryWriter(File.Open("D:\\2.rdlc",FileMode.OpenOrCreate));

bw.Write(Files);

bw.Close();

}
3. c#如何把圖片存取到SQL資料庫
一樓開玩笑了!!可以保存到資料庫的。

首先,你的資料庫里要有一個存放二進制數據的欄位。然後,用一個文件選擇控制項,讓用戶選擇圖片。

用FileStream.Read把圖片文件按照二進制讀取到byte[]中,接下來,鏈接資料庫,用sql語句,進行相應的插入操作,將資料庫的二進制數據的欄位賦值為byte[]就行了。以下是保存和顯示的代碼:private void SaveImage(string fileName) { Read the file into a byte array using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { byte[] imageData = new Byte[fs.Length]; fs.Read(imageData, 0, (int)fs.Length); using (SqlConnection conn = new SqlConnection(connectionString)) { string sql = "insert into image (imagefilename,blobdata) values (@filename,@blobdata)"; Sqlmand cmd = new Sqlmand(sql, conn); cmd.Parameters.Add("@filename",SqlDbType.Text); cmd.Parameters["@filename"].Direction = ParameterDirection.Input; cmd.Parameters.Add("@blobdata", SqlDbType.Image); cmd.Parameters["@blobdata"].Direction = ParameterDirection.Input; Store the byte array within the image field cmd.Parameters["@filename"].Value = fileName; cmd.Parameters["@blobdata"].Value = imageData; conn.Open(); if (cmd.ExecuteNonQuery() == 1) { MessageBox.Show("Done"); } } } } private void LoadImage(string fileName) { using (SqlConnection conn = new SqlConnection(connectionString)) { string sql = "select blobdata from Image where ImageFileName like @filename"; Sqlmand cmd = new Sqlmand(sql, conn); cmd.Parameters.Add("@filename", SqlDbType.Text); cmd.Parameters["@filename"].Value = fileName; conn.Open(); object objImage = cmd.ExecuteScalar(); byte[] buffer = (byte[])objImage; BinaryWriter bw = new BinaryWriter(new FileStream("C:\\abcd.", FileMode.Create)); bw.Write(buffer); bw.Close(); MemoryStream ms = new MemoryStream(buffer); Image bgImage = Image.FromStream(ms); ms.Close(); this.BackgroundImage = bgImage; } } ------------------------------------------------------------------PS:用空情報我踩踩空間,謝謝。

/kxl361。
4. 如何將文件的路徑存入SQL資料庫中去
建一個表:JpgFiles,其中至少包含一個列:JpgPath,用來存放絕對路徑的字元串,所以這個列需要用varchar,長度假設為50,不夠的話自己再增加。

string strPath = @"d:\\up";

string[] fileNames = System.IO.Directory.GetFiles(strPath);

SqlConnection Cn=new SqlConnection(這里寫你的連接串);

Sqlmand Cmd=new Sqlmand("Insert JpgFiles values (@JpgPath)",Cn)

Cmd.Parameters.Add("@JpgPath",SqlDbType.VarChar,50);

foreach (string strName in fileNames)

{

Cmd.Parameters[0].Value=strName;

Cmd.ExecuteNoQuery();

}
5. 怎樣將數據存入mysql資料庫
MySQL命令行導出資料庫:

1,進入MySQL目錄下的bin文件夾:cd MySQL中到bin文件夾的目錄

如我輸入的命令行:cd C:\Program Files\MySQL\MySQL Server 4.1\bin

(或者直接將windows的環境變數path中添加該目錄)

2,導出資料庫:mysqlmp -u 用戶名 -p 資料庫名 >; 導出的文件名

如我輸入的命令行:mysqlmp -u root -p news > news.sql (輸入後會讓你輸入進入MySQL的密碼)

(如果導出單張表的話在資料庫名後面輸入表名即可)

3、會看到文件news.sql自動生成到bin文件下

命令行導入資料庫:

1,將要導入的.sql文件移至bin文件下,這樣的路徑比較方便

2,同上面導出的第1步

3,進入MySQL:mysql -u 用戶名 -p

如我輸入的命令行:mysql -u root -p (輸入同樣後會讓你輸入MySQL的密碼)

4,在MySQL-Front中新建你要建的資料庫,這時是空資料庫,如新建一個名為news的目標資料庫

5,輸入:mysql>use 目標資料庫名

如我輸入的命令行:mysql>use news;

6,導入文件:mysql>source 導入的文件名;

如我輸入的命令行:mysql>source news.sql;
6. 如何把文件存入到sql server 2008
1.MDF文件

在企業管理器中

右擊資料庫

點擊所有任務

附加資料庫

點三個點選擇文件

選中U盤中的MDF文件確定即可

2.BAK等備份文件:

新建空資料庫,取名最好為原資料庫名.

右擊新建的資料庫

點所有任務

點還原資料庫

點從設備

點選擇設備

點添加

定位到U盤中您的備份的文件

確定

點選項

點在現有資料庫上強制還原

點確定

等待

完成!

另外,站長團上有產品團購,便宜有保證

❹ 如果要把資料庫文件添加到sql軟體里,你應該使用什麼命令

導入數據不一定要用OPENSET函數,可以用更簡單的方法,步驟如下:

1、首先雙擊打開sqlserver,右擊需要導入數據的資料庫,如圖所示。