windows系统的服务器怎么访问数据库
发布网友
发布时间:2022-04-29 14:04
我来回答
共1个回答
热心网友
时间:2023-10-09 18:40
VS连接数据库,这里介绍C#的连接方式,
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
/// <summary>
/// DBConnection 的摘要说明
/// </summary>
public class DBConnection
{
private static string connectionString = "";
public DBConnection()
{
//connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
connectionString = "Data Source=localhost;Initial Catalog=myDB;Integrated Security=SSPI";
}
public SqlConnection getDBConnection()