c# 操作mssql数据库 含有带参数sql语句运行
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="Default" value="Default" />
</appSettings>
<connectionStrings>
<add name="Default" connectionString="Data Source=192.168.1.197;User ID=diamond;Password=88888888;Initial Catalog=EmailAnalyse" providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Text;
namespace OfficeOutlook
{
/// <summary>
///DataBase 的摘要说明
/// </summary>
public class DataBase
{
protected SqlConnection BaseSqlConnection = new SqlConnection();//连接对象
protected SqlCommand BaseSqlCommand = new SqlCommand(); //命令对象
public DataBase()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
protected void OpenConnection()
{
if (BaseSqlConnection.State == ConnectionState.Closed) //连接是否关闭
try
{
&nb
相关文档:
public static class AccessHelper
{
//数据库连接字符串
//WebForm
//public static readonly string conn_str = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Request.PhysicalApplicationPath + System.Configuration.ConfigurationManager ......
ASP.NET Excel导入到SQL Server数据库
提供把Excel里的数据导入到SQL Server 数据库,前提是Excel里的字段在Sql Server表里都有,不然会出现错误。注释很详细哦!要引用的命名空间是:
using System.Data.OleDb;
using System.Data.SqlClient;
//操作类
public class ExcelToSQL
{
& ......
@SuppressWarnings("unchecked")
public List<ZxFunction> selectFunctionParentByUserId(final int userId) {
try {
final String sql = "select * from zx_function ......
1:replace 函数
第一个参数你的字符串,第二个参数你想替换的部分,第三个参数你要替换成什么
select replace('lihan','a','b')
&nb ......