请教在Visual C#(winform)中将图片插入oracle数据库并显示的方法和源码!帮忙帮忙!

hometown 2003-08-25 03:01:15
如题!实在是没查到!
多谢!
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hometown 2003-08-26
  • 打赏
  • 举报
回复
请问一下,

string strName, string strType, ref byte[] Buffer


比方我用了一个openFileDialog控件选择文件,要传什么参数进去呢?
jiezhi 2003-08-26
  • 打赏
  • 举报
回复
參考:
// Writes file to the database
private int WriteToDB(string strName, string strType, ref byte[] Buffer)
{
int nFileID = 0;

// Create connection
OleDbConnection dbConn = new OleDbConnection(GetConnectionString());

// Create Adapter
OleDbDataAdapter dbAdapt = new OleDbDataAdapter("SELECT * FROM tblFile", dbConn);

// We need this to get an ID back from the database
dbAdapt.MissingSchemaAction = MissingSchemaAction.AddWithKey;

// Create and initialize CommandBuilder
OleDbCommandBuilder dbCB = new OleDbCommandBuilder(dbAdapt);

// Open Connection
dbConn.Open();

// New DataSet
DataSet dbSet = new DataSet();

// Populate DataSet with data
dbAdapt.Fill(dbSet, "tblFile");

// Get reference to our table
DataTable dbTable = dbSet.Tables["tblFile"];

// Create new row
DataRow dbRow = dbTable.NewRow();

// Store data in the row
dbRow["FileName"] = strName;
dbRow["FileSize"] = Buffer.Length;
dbRow["ContentType"] = strType;
dbRow["FileData"] = Buffer;

// Add row back to table
dbTable.Rows.Add(dbRow);

// Update data source
dbAdapt.Update(dbSet, "tblFile");

// Get newFileID
if( !dbRow.IsNull("FileID") )
nFileID = (int)dbRow["FileID"];

// Close connection
dbConn.Close();

// Return FileID
return nFileID;
}

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧