当前位置:网站首页>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
边栏推荐
- 新唐NUC980设置DHCP或者静态IP
- [eloquence] negotiation persuasion skills and Strategies
- Depth estimation self-monitoring model monodepth2 paper summary and source code analysis [theoretical part]
- 金鱼哥RHCA回忆录:CL210管理存储--对象存储
- jqgrid全选取消单行点击取消事件
- Bond0 script
- [directory blasting tool] information collection stage: robots.txt, Yujian, dirsearch, dirb, gobuster
- RuntimeError: CUDA out of memory(已解决)[通俗易懂]
- ~4.2 CCF 2021-12-1 sequence query
- 元器件采购系统的主要功能,数字化采购助力元器件企业飞速发展
猜你喜欢

The security market has entered a trillion era, and the security B2B online mall platform has been accurately connected to deepen the enterprise development path

How to design a high concurrency system?

Okaleido生态核心权益OKA,尽在聚变Mining模式

Day1: 130 questions in three languages

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

AI model risk assessment Part 1: motivation

阿里云安装MYSQL5.7

Typora cannot open the prompt to install a new version solution
![优质数对的数目[位运算特点+抽象能力考察+分组快速统计]](/img/c9/8f8f0934111f7ae8f8abd656d92f12.png)
优质数对的数目[位运算特点+抽象能力考察+分组快速统计]

Sunfeng, general manager of Yixun: the company has completed the share reform and is preparing for IPO
随机推荐
Introducing mlops interpretation (I)
科隆新能源IPO被终止:拟募资6亿 先进制造与战新基金是股东
Idea regular expression replacement (idea regular search)
The main function of component procurement system, digital procurement helps component enterprises develop rapidly
Realsense-Ros安装配置介绍与问题解决
Emergency science | put away this summer safety guide and let children spend the summer vacation safely!
Under the epidemic, the biomedical industry may usher in breakthrough development
Nuc980 set up SSH xshell connection
How to design a high concurrency system?
thymeleaf通过样式控制display是否显示
[learning record] plt.show() solution to flash back
Throwing OutOfMemoryError “Could not allocate JNI Env“
Gateway 网关报错 SERVICE_UNAVAILABLE
用GaussDB(for Redis)存画像,推荐业务轻松降本60%
Paddlenlp之UIE关系抽取模型【高管关系抽取为例】
Jqgrid select all cancel single line click cancel event
Alibaba cloud installs mysql5.7
DVWA practice - brute force cracking
依迅总经理孙峰:公司已完成股改,准备IPO
pytorch训练代码编写技巧、DataLoader、爱因斯坦标示