地質科學研究資料庫怎麼下載圖
1. 圖片如何存入資料庫
通常對用戶上傳的圖片需要保存到資料庫中。解決方法一般有兩種:一種是將圖片保存的路徑存儲到資料庫;另一種是將圖片以二進制數據流的形式直接寫入資料庫欄位中。以下為具體方法:
一、保存圖片的上傳路徑到資料庫:
string uppath="";//用於保存圖片上傳路徑
//獲取上傳圖片的文件名
string fileFullname = this.FileUpload1.FileName;
//獲取圖片上傳的時間,以時間作為圖片的名字可以防止圖片重名
string dataName = DateTime.Now.ToString("yyyyMMddhhmmss");
//獲取圖片的文件名(不含擴展名)
string fileName = fileFullname.Substring(fileFullname.LastIndexOf("\\") + 1);
//獲取圖片擴展名
string type = fileFullname.Substring(fileFullname.LastIndexOf(".") + 1);
//判斷是否為要求的格式
if (type == "bmp" || type == "jpg" || type == "jpeg" || type == "gif" || type == "JPG" || type == "JPEG" || type == "BMP" || type == "GIF")
{
//將圖片上傳到指定路徑的文件夾
this.FileUpload1.SaveAs(Server.MapPath("~/upload") + "\\" + dataName + "." + type);
//將路徑保存到變數,將該變數的值保存到資料庫相應欄位即可
uppath = "~/upload/" + dataName + "." + type;
}
二、將圖片以二進制數據流直接保存到資料庫:
引用如下命名空間:
using System.Drawing;
using System.IO;
using System.Data.SqlClient;
設計資料庫時,表中相應的欄位類型為iamge
保存:
//圖片路徑
string strPath = this.FileUpload1.PostedFile.FileName.ToString ();
//讀取圖片
FileStream fs = new System.IO.FileStream(strPath, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
byte[] photo = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
//存入
SqlConnection myConn = new SqlConnection("Data Source=.;Initial Catalog=stumanage;User ID=sa;Password=123");
string strComm = " INSERT INTO stuInfo(stuid,stuimage) VALUES(107,@photoBinary )";//操作資料庫語句根據需要修改
SqlCommand myComm = new SqlCommand(strComm, myConn);
myComm.Parameters.Add("@photoBinary", SqlDbType.Binary, photo.Length);
myComm.Parameters["@photoBinary"].Value = photo;
myConn.Open();
if (myComm.ExecuteNonQuery() > 0)
{
this.Label1.Text = "ok";
}
myConn.Close();
讀取:
...連接資料庫字元串省略
mycon.Open();
SqlCommand command = new
SqlCommand("select stuimage from stuInfo where stuid=107", mycon);//查詢語句根據需要修改
byte[] image = (byte[])command.ExecuteScalar ();
//指定從資料庫讀取出來的圖片的保存路徑及名字
string strPath = "~/Upload/zhangsan.JPG";
string strPhotoPath = Server.MapPath(strPath);
//按上面的路徑與名字保存圖片文件
BinaryWriter bw = new BinaryWriter(File.Open(strPhotoPath,FileMode.OpenOrCreate));
bw.Write(image);
bw.Close();
//顯示圖片
this.Image1.ImageUrl = strPath;
採用倆種方式可以根據實際需求靈活選擇。
2. 網站的資料庫文件一般怎麼下載的
網頁資料庫下載的話比較難
如果你是想要知道網站的數據結構的話建議你用軟體去採集數據
有些軟體是可以採集數據用的
不過一般收費的比較有效
3. 怎麼從資料庫讀取圖片數據
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public DataSet ds = null;
public SqlDataAdapter sda = null;
public static SqlConnection conn = null;
//連接資料庫
public void OpenLink()
{
conn = new SqlConnection();
conn.ConnectionString = "Server=192.168.1.5;uid=sa;pwd=555;dataBase=資料庫名";
try
{
conn.Open();
}
catch
{
MessageBox.Show("連接資料庫丟失!");
}
}
//查詢數據表
public void link(String sql)
{
if (conn != null)
{
ds = new DataSet();
sda = new SqlDataAdapter();
sda.SelectCommand = new SqlCommand(sql, conn);
SqlCommandBuilder builder = new SqlCommandBuilder(sda);
sda.Fill(ds);
}
}
public void Pix(PictureBox px, String name) //顯示圖片
{
4. 怎樣把資料庫里的圖片路徑讀出來顯示為圖片
簡單的資料庫操作類
public class conn
{
public OleDbConnection con;
public OleDbCommand command;
public OleDbDataReader dr;
public OleDbDataAdapter ada;
public conn()
{
try
{
con = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source="+System.Web.HttpContext.Current.Server.MapPath("你的資料庫地址"));
con.Open();
}
catch (InvalidOperationException one)
{
System.Web.HttpContext.Current.Response.Write(one.Message);
return;
}
catch (OleDbException two)
{
System.Web.HttpContext.Current.Response.Write(two.Message);
return;
}
}
public void close()
{
con.Close();
}
public void cmd(string str,int m)
{
command = new OleDbCommand(str,con);
try
{
if(m==1)
{
command.ExecuteNonQuery();
}
else
{
dr = command.ExecuteReader();
}
}
catch(InvalidOperationException one)
{
System.Web.HttpContext.Current.Response.Write(one.Message);
return;
}
}
public void da(string str)
{
ada = new OleDbDataAdapter(str,con);
}
}
///////////////////////////以下是操作代碼/////////////
conn con = new conn();打開資料庫
con.cmd("select 資料庫存放圖片路徑的欄位 from 表 where 條件");
if(con.dr.Read())
Response.Write("<img src=\""+con.dr[0].ToString()+"\">");//輸出圖片
else
Response.Write("信息不存在");
con.close();//關閉資料庫
5. 怎麼下載資料庫
你好!
還是建議到官方網站下載!
另外,sqlserver已經有2018 版本的了
你下載的基本沒有什麼公司再用了!
祝你好運!
望採納!
6. 資料庫怎麼存圖片數據
一般來說存相對路徑性能比較好,但需要你處理好數據和文件的同步問題
有的資料庫支持文件類型
7. 資料庫怎麼儲存圖片
資料庫存復儲圖片,其實是存儲圖片制在伺服器上的路徑或圖片的絕對地址 。它是一個字元串,所以資料庫欄位的類型可使用varchar【可變的,長度不超過255】。在前台調用時,需要將路徑放置在img標簽的src屬性中,即可顯示圖片
8. 怎麼在sql資料庫中存放圖片
SQL2000用
方法:
1、建立過程
CREATE PROCEDURE sp_text (
@srvname varchar (30),
@login varchar (30),
@password varchar (30),
@dbname varchar (30),
@tbname varchar (30),
@colname varchar (30),
@filename varchar (30),
@whereclause varchar (40),
@direction char(1))
AS
DECLARE @exec_str varchar (255)
SELECT @exec_str =
'text /S ' + @srvname +
' /U ' + @login +
' /P ' + @password +
' /D ' + @dbname +
' /T ' + @tbname +
' /C ' + @colname +
' /W "' + @whereclause +
'" /F ' + @filename +
' /' + @direction
EXEC master..xp_cmdshell @exec_str
2、建表和初始化數據
create table 表名 (編號 int,image列名 image)
go
insert 表名 values(1,0x) -- 必須的,且不是null
insert 表名 values(2,0x) -- 必須的,且不是null
go
3、讀入
sp_text '你的伺服器名','sa','你的密碼','庫名','表名','image列名','c:\圖片.bmp','where 編號=1','I' --注意條件是 編號=1
sp_text '你的伺服器名','sa','你的密碼','庫名','表名','image列名','c:\bb.doc','where 編號=2','I' --注意條件是 編號=2
go
4、讀出成文件
sp_text '你的伺服器名','sa','你的密碼','庫名','表名','image列名','c:\圖片.bmp','where 編號=1','O' --注意條件是 編號=1
sp_text '你的伺服器名','sa','你的密碼','庫名','表名','image列名','c:\bb.doc','where 編號=2','O' --注意條件是 編號=2
go
************如果報text不是可執行文件的話,你就到
C:\Program Files\Microsoft SQL Server\MSSQL\Binn
目錄下拷備 text.exe到:
C:\Program Files\Microsoft SQL Server\80\Tools\Binn
SQL2005直接用
INSERT INTO myTable(FileName, FileType, Photo)
SELECT 'Roy1.jpg' AS FileName,
'.JPG' AS FileType,
* FROM OPENROWSET(BULK N'C:\Roy1.jpg', SINGLE_BLOB) AS Document
9. 萬方資料庫怎麼下載東西
上面有一個鏈接說caj下載,還有一個鏈接是pdf下載。你點擊就可以了。
不過萬方資料庫是要錢的,如果你沒有注冊過什麼的,應該是下載不下來的
10. 萬方資料庫是怎麼下載呀!怎麼弄去哪裡下載怎麼能找到怎麼搜
1、注冊賬號直復接充值
2、教育網制用戶,在學校內部使用,學生都可以訪問
3、國家圖書館、大部分省級公共圖書館、發達地區的市級公共圖書館館內均可免費下載
4、辦理國家圖書館、大部分省級公共圖書館、發達地區的市級公共圖書館的借書證,用證號訪問圖書館的數字資源,不用親自去圖書館就可下載,但是辦證需要親自去
5、各種圖書館參考咨詢聯盟。注冊一個賬號,足不出戶就可免費獲取文獻。但一般這樣的聯盟有地域限制。
我是湖南省圖書館參考咨詢聯盟的,我們平台叫做聯合在線咨詢,可以直接網路,第一個就是。湖南省范圍外無需注冊直接點擊「我要提問」功能,或掃描二維碼使用「微信咨詢」,輸入需要的論文標題,留下郵箱,提交即可。省內讀者注冊後可獲取全部許可權。