存在从对象类型 System.Web.UI.WebControls.FileUpload 到已知的托管提供程序本机类型的映射

a8265869 2013-10-14 09:42:46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;//这个是WEB.config的应用
using System.Data;///数据集
using System.Data.SqlClient; //数据对象
namespace Test
{
public partial class WebForm1 : System.Web.UI.Page
{
SqlConnection sqlconn = null;
SqlCommand sqlcom = null;
protected void Page_Load(object sender, EventArgs e)
{
string s = ConfigurationManager.AppSettings["coa"];
Open(s);

}
private void Open(string str)
{
sqlconn = new SqlConnection(str);
sqlconn.Open();
}
//插入
public void InsertInfo()
{
string procname = "proc_text";
SqlParameter[] pl = {
new SqlParameter("@data",data.Text),
new SqlParameter("@productID",productID.Text),
new SqlParameter("@ChineseName",ChineseName.Text),
new SqlParameter("@ENName",ENName.Text),
new SqlParameter("@CAS",CAS.Text),
new SqlParameter("@ProducBatch",ProducBatch.Text),
new SqlParameter("@P_MF",P_MF.Text),
new SqlParameter("@P_MW",P_MW.Text),
new SqlParameter("@inamg",FileUpload1),
new SqlParameter("@show",TextBox1.Text),
new SqlParameter("@contents",TextBox47.Text),
new SqlParameter("@Moisture",TextBox48.Text),
new SqlParameter("@Specificrotation",TextBox49.Text),
new SqlParameter("@HeavyMetal",TextBox50.Text),
new SqlParameter("@IR",TextBox51.Text),
new SqlParameter("@Enantiomer",TextBox52.Text),
new SqlParameter("@RelatedSubstances",TextBox53.Text),
new SqlParameter("@NonEnantiomer",TextBox54.Text),
new SqlParameter("@OtherImpurities",TextBox55.Text),
new SqlParameter("@TotalImpurities",TextBox56.Text),
new SqlParameter("@1",TextBox13.Text),
new SqlParameter("@2",TextBox36.Text),
new SqlParameter("@3",TextBox37.Text),
new SqlParameter("@4",TextBox38.Text),
new SqlParameter("@5",TextBox39.Text),
new SqlParameter("@6",TextBox40.Text),
new SqlParameter("@7",TextBox41.Text),
new SqlParameter("@8",TextBox42.Text),
new SqlParameter("@9",TextBox43.Text),
new SqlParameter("@10",TextBox44.Text),
new SqlParameter("@11",TextBox45.Text)
};
try
{
using (sqlcom = new SqlCommand())
{
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Connection = sqlconn;
sqlcom.CommandText = procname;
sqlcom.Parameters.AddRange(pl);
sqlcom.ExecuteNonQuery();
}
}
catch (Exception ex)
{
throw ex;
}
}
//查看
public DataSet selectinfo()
{
DataSet ds = new DataSet();
string procname = "proc_text_1";
SqlParameter[] pl = {
new SqlParameter("@data",data.Text),
new SqlParameter("@productID",productID.Text),
new SqlParameter("@ChineseName",ChineseName.Text),
new SqlParameter("@ENName",ENName.Text),
new SqlParameter("@CAS",CAS.Text),
new SqlParameter("@ProducBatch",ProducBatch.Text),
new SqlParameter("@P_MF",P_MF.Text),
new SqlParameter("@P_MW",P_MW.Text),
new SqlParameter("@inamg",FileUpload1),
new SqlParameter("@show",TextBox1.Text),
new SqlParameter("@contents",TextBox47.Text),
new SqlParameter("@Moisture",TextBox48.Text),
new SqlParameter("@Specificrotation",TextBox49.Text),
new SqlParameter("@HeavyMetal",TextBox50.Text),
new SqlParameter("@IR",TextBox51.Text),
new SqlParameter("@Enantiomer",TextBox52.Text),
new SqlParameter("@RelatedSubstances",TextBox53.Text),
new SqlParameter("@NonEnantiomer",TextBox54.Text),
new SqlParameter("@OtherImpurities",TextBox55.Text),
new SqlParameter("@TotalImpurities",TextBox56.Text),
new SqlParameter("@1",TextBox13.Text),
new SqlParameter("@2",TextBox36.Text),
new SqlParameter("@3",TextBox37.Text),
new SqlParameter("@4",TextBox38.Text),
new SqlParameter("@5",TextBox39.Text),
new SqlParameter("@6",TextBox40.Text),
new SqlParameter("@7",TextBox41.Text),
new SqlParameter("@8",TextBox42.Text),
new SqlParameter("@9",TextBox43.Text),
new SqlParameter("@10",TextBox44.Text),
new SqlParameter("@11",TextBox45.Text)
};
//异常处理
try
{
using (sqlcom = new SqlCommand())
{
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Connection = sqlconn;
sqlcom.CommandText = procname;
sqlcom.Parameters.AddRange(pl);
using (SqlDataAdapter sql = new SqlDataAdapter(sqlcom))
{
sql.Fill(ds);
}
}
}
catch (Exception ex)
{
throw ex;
}
return ds;
}
public DataSet selectinfo1()
{
DataSet ds = new DataSet();
string procname = "proc_text_1";
SqlParameter[] pl = {
};
try
{
using (sqlcom = new SqlCommand())
{
sqlcom.CommandType = CommandType.StoredProcedure;
sqlcom.Connection = sqlconn;
sqlcom.CommandText = procname;
sqlcom.Parameters.AddRange(pl);
using (SqlDataAdapter sql = new SqlDataAdapter(sqlcom))
{
sql.Fill(ds);
}
}
}
catch (Exception ex)
{
throw ex;
}
return ds;
}
protected void Button2_Click_Click(object sender, EventArgs e)
{
selectinfo();
}

protected void Button1_Click_Click(object sender, EventArgs e)
{
string filename = FileUpload1.PostedFile.FileName;
string name = filename.Substring(filename.LastIndexOf("\\") + 1);
FileUpload1.SaveAs(Server.MapPath("/Upload/") + name);
InsertInfo();
}

protected void Button3_Click_Click(object sender, EventArgs e)
{
Response.Redirect("WebForm2.aspx");
}
}
} 这是。cs代码
...全文
132 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
a8265869 2013-10-14
  • 打赏
  • 举报
回复
存在从对象类型 System.Web.UI.WebControls.FileUpload 到已知的托管提供程序本机类型的映射 没有人帮忙看看么

110,535

社区成员

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

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

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