程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> 關於C# >> c#圖片上傳的數據庫部分(自動生成所略圖)

c#圖片上傳的數據庫部分(自動生成所略圖)

編輯:關於C#
 

public int FePicDataSet(string strPicTitle, string strPicDate, string strPicName, int intPicType, string strPicIntro, string strThumbnail, int opID)
{

//string strPicTitle,
//string strPicDate,
//string strPicName,
//int intPicType,
//string strPicIntro,
//string strPicName,
//string strThumbnail,
//int opID
SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
SqlCommand myCommand = new SqlCommand("mag_FePicDataSet", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;

// Add Parameters to SPROC
SqlParameter parameterUserId = new SqlParameter("@opID", SqlDbType.Int);
parameterUserId.Value = opID;
myCommand.Parameters.Add(parameterUserId);

SqlParameter parameterPicTitle = new SqlParameter("@picTitle", SqlDbType.Char, 30);
parameterPicTitle.Value = strPicTitle;
myCommand.Parameters.Add(parameterPicTitle);

SqlParameter parameterPicDate = new SqlParameter("@picDate", SqlDbType.Char, 10);
parameterPicDate.Value = strPicDate;
myCommand.Parameters.Add(parameterPicDate);

SqlParameter parameterPicName = new SqlParameter("@picName", SqlDbType.Char, 50);
parameterPicName.Value = strPicName;
myCommand.Parameters.Add(parameterPicName);

SqlParameter parameterPicType = new SqlParameter("@picType", SqlDbType.Int);
parameterPicType.Value = intPicType;
myCommand.Parameters.Add(parameterPicType);

SqlParameter parameterPicIntro = new SqlParameter("@picIntro", SqlDbType.Char, 255);
parameterPicIntro.Value = strPicIntro;
myCommand.Parameters.Add(parameterPicIntro);

SqlParameter parameterThumbnail = new SqlParameter("@thumbnail", SqlDbType.Char, 50);
parameterThumbnail.Value = strThumbnail;
myCommand.Parameters.Add(parameterThumbnail);

SqlParameter parameterHostAddress = new SqlParameter("@opIP", SqlDbType.Char, 15);
parameterHostAddress.Value = Context.Request.UserHostAddress;
myCommand.Parameters.Add(parameterHostAddress);

//SqlParameter parameterRID = new SqlParameter("@returnID", SqlDbType.Int);
//parameterReturnUserID.Value = -1;
//parameterRID.Direction = ParameterDirection.Output;
//myCommand.Parameters.Add(parameterRID);


// Execute the command in a try/catch to catch duplicate username errors
try
{
// Open the connection and execute the Command
myConnection.Open();
myCommand.ExecuteNonQuery();
}
catch
{

// failed to create a new user
return -1;
}
finally
{

// Close the Connection
if (myConnection.State == ConnectionState.Open)
myConnection.Close();
}

return 1;

}

 


圖片上傳的Codebehind(自動生成所略圖)
www.chinacs.net 2002-2-15 中文C#技術站

 

 

using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using cj168.util;


namespace cj168.Web.Mag.Admins.FeData
{
/// <summary>
/// Summary description for fedata.
/// </summary>
public class feUploadPic : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtboxPicTitle;
protected System.Web.UI.WebControls.Calendar calPicDate;
protected System.Web.UI.WebControls.DropDownList ddlPicType;
protected System.Web.UI.WebControls.TextBox txtboxPicIntro;
protected System.Web.UI.HtmlControls.HtmlInputFile filePicName;
protected System.Web.UI.WebControls.Button btnSubmit;
protected System.Web.UI.WebControls.Label lblPicInfo;
protected System.Web.UI.WebControls.TextBox txtboxPicDate;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator1;
protected System.Web.UI.WebControls.RegularExpressionValidator vldCatName;
protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator2;
protected System.Web.UI.WebControls.CustomValidator CustomValidator1;
protected System.Web.UI.WebControls.RegularExpressionValidator RegularExpressionValidator1;
protected System.Web.UI.WebControls.HyperLink hlkOriPic;
protected System.Web.UI.WebControls.HyperLink hlkNewPic;
protected System.Web.UI.WebControls.RegularExpressionValidator Regularexpressionvalidator2;
protected System.Web.UI.WebControls.RegularExpressionValidator Regularexpressionvalidator3;  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved