当前位置:网站首页>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
边栏推荐
- 手把手教你申请SSL证书
- 安防市场进入万亿时代,安防B2B网上商城平台精准对接深化企业发展路径
- ~4.1 sword finger offer 05. replace spaces
- MySQL table operation
- IDEA设置提交SVN时忽略文件配置
- Mysql表的操作
- thymeleaf通过样式控制display是否显示
- Under the epidemic, the biomedical industry may usher in breakthrough development
- 用GaussDB(for Redis)存画像,推荐业务轻松降本60%
- Why do China Construction and China Railway need this certificate? What is the reason?
猜你喜欢

That day, I installed a database for my sister... Just help her sort out another shortcut

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

手把手教你申请SSL证书

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 2)

51单片机学习笔记(2)

sqli-labs Basic Challenges Less1-10

maya建模练习

Vs2017 large factory ERP management system source code factory general ERP source code

数字孪生 - 认知篇
![Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]](/img/b6/62a346174bfa63fe352f9ef7596bfc.png)
Application practice: Great integrator of the paddy classification model [paddlehub, finetune, prompt]
随机推荐
Filters get the data in data; Filters use data in data
实现一个家庭安防与环境监测系统(一)
Introduction to PHP
Day1: 130 questions in three languages
swiper 一侧或两侧露出一小部分
telnet远程登录aaa模式详解【华为eNSP】
Mongodb源码部署以及配置
sqli-labs Basic Challenges Less1-10
Reverse Integer
如何设计一个高并发系统?
OKA通证权益解析,参与Okaleido生态建设的不二之选
CDA level Ⅰ 2021 new version simulation question 1 (with answers)
What you must know about data engineering in mlops
jqgrid全选取消单行点击取消事件
Oka pass rights and interests analysis is the best choice to participate in okaleido ecological construction
[original] nine point calibration tool for robot head camera calibration
sudo rosdep init Error ROS安装问题解决方案
CDA level1 double disk summary
Goldfish rhca memoirs: cl210 management storage -- object storage
【cartographer_ros】八: 官方Demo参数配置和效果