文件名未保存 [英] File name not stored

查看:94
本文介绍了文件名未保存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个网站,我必须插入客户记录以及图像插入和图像文件路径名

I have created a website and I have to insert the customer record and image insert and image file path name

public partial class WebForm1 : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
         {
              onflbload(sender, e);
        }
        public void onflbload(object sender, EventArgs e)
        {
            // Create a byte[] from the input file
            int len = flbload.PostedFile.ContentLength;
            byte[] pic = new byte[len];
            flbload.PostedFile.InputStream.Read(pic, 0, len);
            // Insert the image and comment into the database
            SqlConnection connection = new SqlConnection(@"Data Source=DEVI\SQLEXPRESS; 
                          Initial Catalog =cat; Integrated Security=SSPI");
            SqlConnection con = new SqlConnection();
            con.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
            try
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "photoset";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
                cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value = TextBox2.Text;
                cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
                cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value = Rdbsdate.SelectedDate;
                cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value = Rdbddate.SelectedDate;                   
                                
                cmd.Parameters.Add("@Systemurl", SqlDbType.Image).Value = pic;
                SqlParameter Src = new SqlParameter("@FilePath", SqlDbType.VarChar, 450);
                Src.Value = flbload.PostedFile.FileName;
                cmd.Parameters.Add(Src);
                cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value = TextBox7.Text;
                cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
                cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
            }
        }
    }
}

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[photoset]
(
@BillNo Numeric,
@CustomerName Nvarchar(300),
@Address Nvarchar(300),
@StartDate datetime,
@EndDate datetime,
@Systemurl image,
@Filepath Nvarchar,
@Numberofcopies Numeric,
@Amount Numeric,
@Total Numeric
)
 
AS
BEGIN
 insert into tblphotosettings
(
BillNo,
CustomerName,
Address,
StartDate,
EndDate,
Systemurl,
Filepath,
Numberofcopies,
Amount,
Total
)
values
(
@BillNo,
@CustomerName,
@Address,
@StartDate,
@EndDate,
@Systemurl,
@Filepath,
@Numberofcopies,
@Amount,
@Total
)
END


我的错误所有记录都是插入的,但文件名不是insert


My Error All record are insert but file name not insert

推荐答案

更改问题的主题不会更改结果:请阅读最后五遍的答案问这个问题,然后尝试学习思考!
Changing the subject of your question will not change the results: Read the answers to the last five times you have asked this question, and try learn to think!


假设您的意思是Filepath,那么问题可能出在这里:

Assuming you mean Filepath, the problem may be here:

@Filepath Nvarchar



尝试将长度添加到参数声明中,看看是否有帮助:



Try adding a length to your parameter declaration and see if it helps:

@Filepath Nvarchar(450)


这篇关于文件名未保存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆