I would picture name stored in the database, but how could not be read, ask for

string filename = FileUpload1.PostedFile.FileName;
if (filename.LastIndexOf("\\") <0)
{
name = filename;
}
else
{
name = filename.Substring(filename.LastIndexOf("\\") + 1);
}
FileUpload1.SaveAs(Server.MapPath("/Upload/") + name);



This is read into the database code, the name of the picture can be saved in database, but when read from a database error, and read the picture from the database code, need to read the cards picture picture controls in image,

Started by Silvester at February 08, 2016 - 1:59 PM

I have just started to learn the c# doesn't know.

Posted by Ken at February 09, 2016 - 2:35 PM

Funny, database where

Posted by Silvester at February 11, 2016 - 3:31 PM

This is the file operation.?

Posted by Winnie at February 21, 2016 - 3:37 PM

This is the file operation.?

Posted by Arno at November 28, 2016 - 9:53 AM

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;//This is a WEB.config application
using System.Data;///Data set
using System.Data.SqlClient; //The data object

namespace Test
{
public partial class WebForm3 : System.Web.UI.Page
{
SqlConnection sqlconn = null;
SqlCommand sqlcom = null;
string name = "";
protected void Page_Load(object sender, EventArgs e)
{
///Get your config configuration database connection string
string s = ConfigurationManager.AppSettings["coa"];
Open(s);

///Page Jump
//Response.Redirect("Default.aspx");
}
private void Open(string str)
{
sqlconn = new SqlConnection(str);
sqlconn.Open();
}

public DataSet selectinfo()
{
DataSet ds = new DataSet();
string procname = "proc_text_1";
SqlParameter[] pl = {
new SqlParameter("@data",TextBox3.Text),
new SqlParameter("@productID",TextBox4.Text),
new SqlParameter("@ChineseName",TextBox5.Text),
new SqlParameter("@ENName",TextBox6.Text),
new SqlParameter("@CAS",TextBox7.Text),
new SqlParameter("@ProducBatch",TextBox8.Text),
new SqlParameter("@P_MF",TextBox9.Text),
new SqlParameter("@P_MW",TextBox10.Text),
new SqlParameter("@inamg",Image1),
new SqlParameter("@show",TextBox12.Text),
new SqlParameter("@contents",TextBox13.Text),
new SqlParameter("@Moisture",TextBox14.Text),
new SqlParameter("@Specificrotation",TextBox15.Text),
new SqlParameter("@HeavyMetal",TextBox16.Text),
new SqlParameter("@IR",TextBox17.Text),
new SqlParameter("@Enantiomer",TextBox18.Text),
new SqlParameter("@RelatedSubstances",TextBox19.Text),
new SqlParameter("@NonEnantiomer",TextBox20.Text),
new SqlParameter("@OtherImpurities",TextBox21.Text),
new SqlParameter("@TotalImpurities",TextBox22.Text),
new SqlParameter("@1",TextBox23.Text),
new SqlParameter("@2",TextBox24.Text),
new SqlParameter("@3",TextBox25.Text),
new SqlParameter("@4",TextBox26.Text),
new SqlParameter("@5",TextBox27.Text),
new SqlParameter("@6",TextBox28.Text),
new SqlParameter("@7",TextBox29.Text),
new SqlParameter("@8",TextBox30.Text),
new SqlParameter("@9",TextBox31.Text),
new SqlParameter("@10",TextBox32.Text),
new SqlParameter("@11",TextBox33.Text),
new SqlParameter("@CD1",TextBox34.Text),
new SqlParameter("@CD2",TextBox35.Text),
new SqlParameter("@CD3",TextBox36.Text),
new SqlParameter("@CD4",TextBox37.Text),
new SqlParameter("@CD5",TextBox38.Text),
new SqlParameter("@CD6",TextBox39.Text),
new SqlParameter("@CD7",TextBox40.Text),
new SqlParameter("@CD8",TextBox41.Text),
new SqlParameter("@CD9",TextBox42.Text),
new SqlParameter("@CD10",TextBox43.Text),
new SqlParameter("@CD11",TextBox44.Text)
};
//Exception handling
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 GetDataInfo()
{
DataSet ds = new DataSet();
string procname = "test_proc_Test";
SqlParameter[] pl = {
new SqlParameter("@productID",TextBox1.Text),
new SqlParameter("@ProducBatch",TextBox2.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;
}
protected void Button1_Click(object sender, EventArgs e)
{
selectinfo();

}
}
selectinfo(); There should be how to write to read

Posted by Charlotte at December 09, 2016 - 10:34 AM

Learn to break point, single step debugging. . .

Posted by Charlotte at December 24, 2016 - 11:11 AM

Does not exist to provide mapping program the machine type from an object of type System.Web.UI.WebControls.Image to a known managed.
Always report this error.

Posted by Silvester at December 29, 2016 - 11:49 AM

It is strange.
You put the file name in the data, and then fetched from the database.
This is a string of access, this should be no problem.
The rest is the file name in the file format to read read good.
Or directly assigned to a image control.

Posted by Cora at January 09, 2017 - 12:52 PM

Now just don't understand how to specify the image control

Posted by Silvester at January 11, 2017 - 12:34 PM

To find the "7 days" to read again ask the master asp.net.

Posted by Helena at January 13, 2017 - 1:08 PM