110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Collections;
using System.ComponentModel;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
namespace SqlDataConfig
{
public class DateLink
{
public SqlConnection myConn;
public string ServerStr;
static string server; //服务器地址
static string uid; //用户名
static string pwd; //密码
static string database; //数据库名称
public static void setServer(string get_server)
{
server = get_server;
}
public static void setUid(string get_uid)
{
uid = get_uid;
}
public static void setPwd(string get_pwd)
{
pwd = get_pwd;
}
public static void setDatabase(string get_database)
{
database = get_database;
}
public DateLink()
{
ServerStr = @"Server=" + server + ";Database=" + database + ";User=" + uid + ";PWD=" + pwd;
myConn = new SqlConnection(ServerStr);//出错提示行:“System.Data.SqlClient.SqlConnection”的类型初始值设定项引发异常。
}
public void Open()
{
myConn.Open();
}
public void Close()
{
myConn.Close();
}
public int tOpen()
{
try
{
myConn.Open();
return 1;
}
catch
{
return 0;
}
}
}
}
DateLink.setServer("127.0.0.1");
DateLink.setUid("sa");
DateLink.setPwd("");
DateLink.setDatabase("AssetManagement");
DateLink MyDL = new DateLink();