⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 info.aspx.cs

📁 这是asp.net^和Visual C++Sharp编写的串并口通讯的书籍 源代码
💻 CS
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Drawing;


public partial class _InFo : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            SqlConnection con = new SqlConnection("server=(local);user id=sa;pwd=;database=mrdb");
            SqlDataAdapter ada = new SqlDataAdapter("select * from tb_15 ", con);
            con.Open();
            DataSet ds = new DataSet();
            ada.Fill(ds);
            DropDownList1.DataSource = ds;
            DropDownList1.DataTextField = "id";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();
            Image1.Visible=false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Image1.Visible = true;
        SqlConnection con = new SqlConnection("server=(local);user id=sa;pwd=;database=mrdb");
        string imagename = "";
        try
        {
            con.Open();
            SqlCommand com = new SqlCommand("select name from tb_15 where id=" + DropDownList1.Text + "", con);
            SqlDataReader dr = com.ExecuteReader();
            dr.Read();
            MemoryStream ms = new MemoryStream((Byte[])dr["name"]);
            Bitmap image = new Bitmap(ms);
            string filepath = Server.MapPath("Files/");
            DirectoryInfo dir = new DirectoryInfo(filepath);
            FileInfo[] filecount = dir.GetFiles();
            int i = filecount.Length;
            imagename = filepath + ".jpg";
            image.Save(imagename);
            dr.Close();
            Image1.ImageUrl = "Files/" + ".jpg";
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
        finally
        {
            con.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -