以下是我在visual studio 2005上写的一个类(连的是SQL Server 2005),已经过测试通过。里面有3个方法比较典型,源码如下:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace DatabaseOperate
{
class SqlOperateInfo
{
//Suppose your ServerName is "aa",DatabaseName is "bb",UserName is "cc", Password is "dd"
private string sqlConnectionCommand = "Data Source=aa;Initial Catalog=bb;User ID=cc;Pwd=dd";
//This table contains two columns:KeywordID int not null,KeywordName varchar(100) not null
private string dataTableName = "Basic_Keyword_Test";
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/