惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
Kaspersky official blog
Martin Fowler
Martin Fowler
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
博客园_首页
Engineering at Meta
Engineering at Meta
The Cloudflare Blog
MongoDB | Blog
MongoDB | Blog
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
雷峰网
雷峰网
D
Docker
博客园 - 司徒正美
S
SegmentFault 最新的问题
M
MIT News - Artificial intelligence
博客园 - 叶小钗
博客园 - 三生石上(FineUI控件)
U
Unit 42
J
Java Code Geeks
A
About on SuperTechFans
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
S
Security Affairs
I
Intezer
Cisco Talos Blog
Cisco Talos Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
B
Blog RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Tenable Blog
T
Threatpost
H
Hacker News: Front Page
G
Google Developers Blog
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
Apple Machine Learning Research
Apple Machine Learning Research
L
Lohrmann on Cybersecurity
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
A
Arctic Wolf
S
Secure Thoughts
GbyAI
GbyAI
NISL@THU
NISL@THU
S
Security @ Cisco Blogs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Webroot Blog
Webroot Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
O
OpenAI News
Spread Privacy
Spread Privacy
Application and Cybersecurity Blog
Application and Cybersecurity Blog

博客园 - 数迹

1.winform中App.config配置mssql连接字符串 where关键字 1.params 关键字 1.创建实体类UserInfo 1. UserInfo表的创建 3.SqlCommand组件 2.在DbHelper.cs 中使用连接字符串 事件委托1 多播委托 委托总结:委托提供了 A类的对象 调用 B类对象的同一类方法 的能力。 委托3--委托声明比较 委托2 文心快码 委托1 sql提示注册表中无 \100\ConfigurationState的解决方法 - 数迹 - 博客园 安装SQL server 提示重新启动计算机失败怎么解决 DataGridView插入指定类型的列 ${pagecontext.request.contextpath}绝对路径理解 eclipse中修改JSP模板中的默认编码 hibernate的ddl-auto属性
菜单制作过程笔记1
数迹 · 2022-03-23 · via 博客园 - 数迹

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Menu
{
class Program
{
static void Main(string[] args)
{
//获取菜单中父id为0的记录 list中的每个对象对应数据库中一条记录
List<MenuInfosMod> list = new List<MenuInfosMod>();
string connStr = "Data Source=WIN-MR86JSLEADS\\CCNN;Initial Catalog=Myschool;Integrated Security=True";
SqlConnection conn = new SqlConnection(connStr);
string cmdText = "select * from MenuInfos where ParentId=0";
SqlCommand cmd = new SqlCommand(cmdText,conn);
conn.Open();
SqlDataReader dr = cmd.ExecuteReader();
Console.WriteLine(dr.ToString());
//获取dr中的字段个数
//Console.WriteLine(dr.FieldCount.ToString());
//for (int i = 0; i < dr.FieldCount; i++)
//{
// Console.WriteLine(dr.GetName(i)+" ");
//}
while(dr.Read()){
//dr[下标] dr[“字段名”]都可以
MenuInfosMod menuInfo = new MenuInfosMod();
menuInfo.MenuId = int.Parse(dr["MenuId"].ToString());
menuInfo.MenuName = dr["MenuName"].ToString();
menuInfo.ParentId = int.Parse(dr["ParentId"].ToString());
menuInfo.FrmName = dr["FrmName"].ToString();
list.Add(menuInfo);
}
//遍历list
//foreach (MenuInfosMod item in list)
//{
// Console.WriteLine(item.MenuName+" "+item.MenuId);
//}
//创建树
conn.Close();
Console.ReadKey();

}
}
}