我设计我的网页:插入图像和thenfilepath到数据库
namespace photoshops
{
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");
try
{
connection.Open();
SqlCommand cmd = new SqlCommand("insert into tblphotosettings " +
"(BillNo,CustomerName,Address,StartDate,EndDate,Systemurl,Numberofcopies,Amount,Total)
values (@BillNo,@CustomerName,@Address,@StartDate,@EndDate,@Systemurl,@Numberofcopies,@Amount,@Total)", connection);
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 = pic.GetName();
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.ExecuteNonQuery();
}
finally
{
connection.Close();
}
}
}
}
我的错误
Error 1 'System.Array' does not contain a definition for 'GetName'
and no extension method 'GetName' accepting a first argument of type 'System.Array' could
be found (are you missing a using directive or an assembly reference?)
C:\Documents and Settings\Administrator\My Documents\Visual Studio
2008\Projects\photoshops\photoshops\photosetting.aspx.cs 52 29 photoshops
一个offtopic的评论︰System.Windows.Forms.MessageBox.Show - 将无法在ASPX – Anuraj 2011-03-25 06:26:49
@vs dev它不是真实的,它会工作,但它会显示在服务器端 – 2011-03-25 06:45:56
这里没有问题。 – carlsb3rg 2011-03-25 06:49:30