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

📄 addstoreorder.cs

📁 利用vs2008+sql2000开发的物资管理系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient; 

namespace login
{
    public partial class addstoreorder : Form
    {
       

        public string pName = "";

        
        public addstoreorder()
        {
            InitializeComponent();
        }

        private void addstoreorder_Load(object sender, EventArgs e)
        {
            String constr = "Data Source=localhost; Initial Catalog=WZGL_20052070;Integrated Security=true";
            SqlConnection scon = new SqlConnection(constr);

            SqlDataAdapter sa = new SqlDataAdapter();

            

            string sqlStatement = "select *from room where pname=@ID ";	// 构造查询语句
    // 创建SQL命令对象
   
           SqlCommand storescommand = new SqlCommand(sqlStatement,scon);


           storescommand.Parameters.AddWithValue("@ID", pName);
           scon.Open();		// 打开连接
           SqlDataReader sdr = storescommand.ExecuteReader();// 执行SQL语句
           int cols = sdr.FieldCount;	// 获取结果行中的列数

           listView1.BeginUpdate();
           // 向列表视图中添加列表头
           for (int i = 0; i < cols; i++)
           {
               listView1.Columns.Add(sdr.GetName(i), 100, HorizontalAlignment.Left);
           }

           string[] lvitem = new string[cols];
           object[] values = new object[cols];
           // 向列表视图中添加列表项
           while (sdr.Read())
           {
               sdr.GetValues(values);		// 读取一行
               for (int i = 0; i < values.Length; i++)
                   lvitem[i] = values[i].ToString();
               ListViewItem lvi = new ListViewItem(lvitem);
               listView1.Items.Add(lvi);
           }
           listView1.EndUpdate();
           sdr.Close();
           scon.Close();


           

        }
    }
}

⌨️ 快捷键说明

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