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

📄 form2.cs

📁 用Csharp编写的一个图书馆里系统
💻 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 WindowsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string str = this.textBox2.Text.Trim();
            this.dgvShowBookInfo.Rows.Clear();
            try
            {
                SqlConnection conn = new SqlConnection(@"Data Source=.;Initial Catalog=tushu; Integrated Security=True");
                string sql = "select * from booktable where authorna=@chubanshe";
                SqlCommand cmmd = new SqlCommand(sql, conn);
                SqlParameter pChubanshe = new SqlParameter("@chubanshe", SqlDbType.VarChar);
                pChubanshe.Value = str;
                cmmd.Parameters.Add(pChubanshe);
                SqlDataAdapter Adapter = new SqlDataAdapter(cmmd);
                DataSet ds = new DataSet();
                Adapter.Fill(ds, "booktable");
                for (int i = 0; i < ds.Tables["booktable"].Rows.Count; i++)
                {
                    this.dgvShowBookInfo.Rows.Add(ds.Tables["booktable"].Rows[i][0],
                                                  ds.Tables["booktable"].Rows[i][1],
                                                  ds.Tables["booktable"].Rows[i][2],
                                                  ds.Tables["booktable"].Rows[i][3],
                                                  ds.Tables["booktable"].Rows[i][4],
                                                  ds.Tables["booktable"].Rows[i][5],
                                                  ds.Tables["booktable"].Rows[i][6]);
                }

            }
            finally
            {
                
            }
        }
    }
}

⌨️ 快捷键说明

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