Form2.cs

(完整代码) 1KB

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace WindowsFormsApplication1
{  
   
    public partial class Form2 : Form
    { 
        public Form2()
        {
            InitializeComponent();
        }

        private void Form2_Load(object sender, EventArgs e)
        { 
            string connstr = "server=.\\sql2005;database=mytest;uid=sa;pwd=sa";// uid=sa;pwd=123456";//
            using (SqlConnection conn = new SqlConnection(connstr))
            {
                SqlCommand cmd = new SqlCommand();
                string sqlstr = "select * from  StuInfo";
                cmd.Connection = conn;
                cmd.CommandText = sqlstr;
                conn.Open();
                SqlDataReader dr = cmd.ExecuteReader();
             //   BindingManagerBase bind = null;


                BindingSource bs = new BindingSource();
                bs.DataSource = dr;
            dataGridView1 .DataSource=bs;
            }

        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
    }
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。