How to put SQL

xiaoxiao2021-03-06  117

First build a file show.aspx that displays the picture, where the show.aspx.cs file is written:

Private Void Page_Load (Object Sender, System.EventArgs E)

{

/ / Place the user code here to initialize the page

SqlConnection conn = new sqlconnection (configurationSettings.appsettings ["connStr"]. TOSTRING ());

Cn.open ();

String ID = Request.QueryString ["ID"];

DataSet DS = New DataSet ();

BYTE [] mydata = new byte [0];

Sqldataadapter Da = New SqldataAdapter ("Select Picture from TableName Where ID =" ID, CONN);

Da.fill (DS, "Product");

DataRow myrow;

Myrow = ds.tables ["Tablename"]. Rows [0];

IF (Myrow ["Picture"]. TOSTRING ()! = "")

MyData = (byte []) Myrow ["Picture"];

Response.contentType = "jpg";

Response.binaryWrite (MyData);

}

Then write on the file you want to display the image:

To display the file and show.aspx in the same path.

转载请注明原文地址:https://www.9cbs.com/read-99945.html

New Post(0)