当前位置:编程学习 > C#/ASP.NET >>

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

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代码 --------------------编程问答-------------------- 存在从对象类型 System.Web.UI.WebControls.FileUpload 到已知的托管提供程序本机类型的映射    没有人帮忙看看么
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,