Sql与C#连接问题(1)

                                                    菜鸟第一篇
1、先在web.config里先如下进行定义:
//####################
<configuration>
 <appSettings>
  <add key="ConnectionString" value="Server=(local);Database=jxt;Integrated Security=True;"/>
//#####################
2、静态变量进行总体申明
//##########################
   public static SqlConnection GetConnection()
     {
        SqlConnection connection = new SqlConnection(DbConfig.DbConnectString);
        connection.Open();
        return connection;
    }
//############################
3、将需要写入后台的数据库里的内容直接按如下语句进行写入
//##########################
SqlConnection connection = DbHelper.GetConnection();
            SqlParameter [] Param = new SqlParameter[1];
            Param[0] = new SqlParameter("BODY", SqlDbType.NVarChar,2000);
            Param[0].Value = FCKeditorDll.Value;
         return   SqlHelper.ExecuteNonQuery(connection,CommandType.StoredProcedure,"",Param);
//#################################
posted on 2009-08-05 17:39  遥望大海,云卷云舒  阅读(377)  评论(0编辑  收藏  举报