当前位置:网站首页>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
边栏推荐
- Difference between pregnancy box and delivery box
- 进程间通信 -- 消息队列
- The songbird document editor will be open source: starting with but not limited to markdown
- Detailed introduction to paging exploration of MySQL index optimization
- After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before
- web三大组件(Servlet,Filter,Listener)
- qt 64位静态版本显示gif
- Write console script by laravel
- 用curl库压缩成发送字符串为utf8并用curl库发送
- Jupyter Lab 十大高生产力插件
猜你喜欢

nacos基础(6):nacos配置管理模型

The songbird document editor will be open source: starting with but not limited to markdown

SVN的使用:

redis优化系列(二)Redis主从原理、主从常用配置

MIT: label every pixel in the world with unsupervised! Humans: no more 800 hours for an hour of video

26. Delete duplicates in ordered array

Write console script by laravel

Canvas详解

After the MySQL router is reinstalled, it reconnects to the cluster for boot - a problem that has been configured in this host before

MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
随机推荐
redis优化系列(二)Redis主从原理、主从常用配置
Go interface usage
MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
Mysql8. 0 installation guide
26. Delete duplicates in ordered array
Database management software sqlpro for SQLite for Mac 2022.30
nacos基础(5):nacos配置入门
About the three commonly used auxiliary classes of JUC
MySQL failed to insert the datetime type field without single quotation marks
Learning go language 0x02: understanding slice
Mysql中有关Datetime和Timestamp的使用总结
Usage Summary of datetime and timestamp in MySQL
MySQL sorting feature details
Learn go language 0x07: stringer exercise code in go language journey
MySQL对数据表已有表进行分区表的实现
活动进行时! 点击链接加入直播间参与“AI真的能节能吗?”的讨论吧!
qt5.8 64 位静态库中想使用sqlite但静态库没有编译支持库的方法
Excel · VBA array bubble sorting function
Common parameters of ffmpeg command line
Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities