当前位置:网站首页>C language and SQL Server database technology
C language and SQL Server database technology
2022-07-25 14:24:00 【yushang_ zhang】
Use ADO.NET Access database
One 、 Use ADO.NET Access database
1.ADO.NET yes .net framework An important part of
2. yes .net A technology used by the platform to access databases
3. To operate the database, you first need to connect to the database
4. Connecting to different databases requires different data providers
5. operation SQL Server The database USES SqlConnection This class , stay System.Date.SqlClient Namespace
6. To connect to the database, you need to provide connection information , These connection information is written in a connection string
a、Data Source Specify the server where the database is located , It can be localhost perhaps ip Address
b、Initial Catalog Specify the database to operate
c、User ID Specify user name
d、pwd Specified password
7. The connection string can be through vs To generate
8. Call the... Of the connection object open() Method to open the connection
9. Remember to call close() Method to close the connection , Release resources
10. matters needing attention :
a、 The items in the connection string are separated by English semicolons
b、 Server's IP Address 、 Don't write the user name and password wrong
c、 Make sure that the database service is started
Two 、 Use ExecuteScalar Query data
1. You need to execute the query statement , Need to put sql Statements are sent to the database
2.SqlCommand Object is used to sql Statements are sent to the database
3.SqlCommand Object's ExecuteScalar() Method is used to query the value of the first row and the first column in the result
4. matters needing attention :
a、 Remember to open the database before operation
b、ExecuteScalar() Remember the data type conversion of the returned demerit recording
3、 ... and 、 exception handling
1. The program will inevitably be abnormal
2. After the abnormal , If the program breaks , So the user experience is poor
3. You can usually consider using try catch Catch exceptions
4.try It contains code that may cause exceptions
5. If there is an anomaly , entering catch() Intermediate processing
边栏推荐
- CTS测试介绍(面试怎么介绍接口测试)
- Maya modeling exercise
- CDA level1 double disk summary
- Runtimeerror: CUDA out of memory (solved) [easy to understand]
- From fish eye to look around to multi task King bombing -- a review of Valeo's classic articles on visual depth estimation (from fisheyedistancenet to omnidet) (Part I)
- CDA level Ⅰ 2021 new version simulation question 2 (with answers)
- einsum(): operands do not broadcast with remapped shapes [original->remapped]: [1, 144, 20, 17]->[1,
- OverTheWire-Natas
- 手把手教你申请SSL证书
- Melodic + Realsense D435i 配置及错误问题解决
猜你喜欢

基于PaddleOCR开发uni-app离线身份证识别插件

PHP website design ideas

filters获取data中的数据;filters使用data中的数据

Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction

The practice of depth estimation self-monitoring model monodepth2 in its own data set -- single card / multi card training, reasoning, onnx transformation and quantitative index evaluation

The main function of component procurement system, digital procurement helps component enterprises develop rapidly

IDEA报错 Failed to determine a suitable driver class

NUC980 设置SSH Xshell连接

Under the epidemic, the biomedical industry may usher in breakthrough development

飞沃科技IPO过会:年营收11.3亿 湖南文旅与沅澧投资是股东
随机推荐
Keys and scan based on redis delete keys with TTL -1
Mysql表的操作
Word set paste to retain only text
Can the variable name be in Chinese? Directly fooled people
Emergency science | put away this summer safety guide and let children spend the summer vacation safely!
Easy entry natural language processing series 12 hidden Markov models
Realize a family security and environmental monitoring system (I)
Mlops column introduction
Sunfeng, general manager of Yixun: the company has completed the share reform and is preparing for IPO
Detailed explanation of how R language converts large Excel files into DTA format
Practical guide for network security emergency response technology (Qianxin)
如何设计一个高并发系统?
Products on Apple's official website can save 600 yuan by buying iPhone 13 Pro max at a discount
Realsense-Ros安装配置介绍与问题解决
Nuc980 set up SSH xshell connection
依迅总经理孙峰:公司已完成股改,准备IPO
Four methods of importing CSV text files into Excel
Polymorphism and interface
Deep understanding of pytorch distributed parallel processing tool DDP -- starting from bugs in engineering practice
苹果手机端同步不成功,退出登录,结果再也登录不了了