当前位置:网站首页>Study notes of C [8] SQL [1]
Study notes of C [8] SQL [1]
2022-04-23 11:18:00 【BoomBiuBiu】
Download here SQL, I downloaded it 2019 edition , The installation link is placed below :
Some problems will be encountered during installation , You can see the following link , Basically solve the problem :
【 example 1】 Create a connection with the native SQL Server Database connection , And use exception handling .
According to the title requirements , Connect SQL Server The user name used for database is sa、 The password for 123456789,【 The account and password here can be set by yourself 】 The database connected is Test.【 Pay attention to the name on your database 】, There was a problem signing in here , You can see the following link :
Need to be in SQL Create a new database named Test The database of , To show that the link is successful
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SQL
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// Write database connection string
string connStr = "Data source=.;Initial Catalog=Test;User ID=sa;Password=123456789";
// establish SqlConnection Example
SqlConnection conn = null;
try
{
conn = new SqlConnection(connStr);
// Open database connection
conn.Open();
MessageBox.Show(" Database connection successful !");
}
catch (Exception ex)
{
MessageBox.Show(" Database connection failed !" + ex.Message);
}
finally
{
if (conn != null)
{
// Close database connection
conn.Close();
}
}
}
}
}
版权声明
本文为[BoomBiuBiu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231115284400.html
边栏推荐
- ffmpeg命令行常用参数
- Learn go language 0x04: Code of exercises sliced in go language journey
- 卷积层和池化层总结
- How to use JDBC callablestatement The wasnull () method is called to check whether the value of the last out parameter is SQL null
- Use of SVN:
- Learning website materials
- VM set up static virtual machine
- map<QString, bool> 的使用记录
- R-Drop:更强大的Dropout正则方法
- After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
猜你喜欢
语雀文档编辑器将开源:始于但不止于Markdown
CUMCM 2021-b: preparation of C4 olefins by ethanol coupling (2)
升级cpolar内网穿透能获得的功能
Promise details
laravel编写Console脚本
Constraintlayout layout
Learn go language 0x04: Code of exercises sliced in go language journey
MIT: label every pixel in the world with unsupervised! Humans: no more 800 hours for an hour of video
VM set up static virtual machine
Use of SVN:
随机推荐
Upgrade the functions available for cpolar intranet penetration
CUMCM 2021-B:乙醇偶合制备C4烯烃(2)
MIT: label every pixel in the world with unsupervised! Humans: no more 800 hours for an hour of video
Structure of C language (Advanced)
AcWing 1874. 哞加密(枚举,哈希)
妊娠箱和分娩箱的区别
Learn go language 0x04: Code of exercises sliced in go language journey
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
学习 Go 语言 0x08:《Go 语言之旅》中 练习使用 error
An interesting interview question
More reliable model art than deep learning
How to use JDBC callablestatement The wasnull () method is called to check whether the value of the last out parameter is SQL null
学习 Go 语言 0x04:《Go 语言之旅》中切片的练习题代码
Mysql8.0安装指南
Learn go language 0x07: stringer exercise code in go language journey
Promise details
remote: Support for password authentication was removed on August 13, 2021.
Get things technology network optimization - CDN resource request Optimization Practice
nacos基础(6):nacos配置管理模型
Detailed explanation of typora Grammar (I)