在Asp.Net上使用fusionchart报表 图解
?
?
?
?
?
?
using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace MYASP
{
? ? public class SQLDBHelper
? ? {
? ? ? ? static string str = ConfigurationManager.ConnectionStrings["SqlCon"].ToString();
? ? ? ? /// <summary>
? ? ? ? /// 增 删 改方法
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static int ExecuteNonQuery(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? int result = -1;
? ? ? ? ? ? using (SqlConnection con = new SqlConnection(str))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? ? ? result = cmd.ExecuteNonQuery();
? ? ? ? ? ? }
? ? ? ? ? ? return result;
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 提取共同方法
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <param name="con"></param>
? ? ? ? /// <param name="cmd"></param>
? ? ? ? private static void PrepareSQLCommand(CommandType cmdType, string sql, SqlParameter[] parms, SqlConnection con, SqlCommand cmd)
? ? ? ? {
? ? ? ? ? ? cmd.Connection = con;
? ? ? ? ? ? if (con.State != ConnectionState.Open)
? ? ? ? ? ? ? ? con.Open();
? ? ? ? ? ? cmd.CommandText = sql;
? ? ? ? ? ? cmd.CommandType = cmdType;
? ? ? ? ? ? if (parms != null)
? ? ? ? ? ? ? ? foreach (SqlParameter parm in parms)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? cmd.Parameters.Add(parm);
? ? ? ? ? ? ? ? }
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 查询
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static SqlDataReader ExecuteReader(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? SqlConnection con = new SqlConnection(str);
? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? SqlDataReader reader = cmd.ExecuteReader();
? ? ? ? ? ? return reader;
? ? ? ? }
? ? ? ? /// <summary>
? ? ? ? /// 读取单个值
? ? ? ? /// </summary>
? ? ? ? /// <param name="cmdType"></param>
? ? ? ? /// <param name="sql"></param>
? ? ? ? /// <param name="parms"></param>
? ? ? ? /// <returns></returns>
? ? ? ? public static int ExecuteScalar(CommandType cmdType, string sql, SqlParameter[] parms)
? ? ? ? {
? ? ? ? ? ? int result = -1;
? ? ? ? ? ? //连接数据库
? ? ? ? ? ? using (SqlConnection con = new SqlConnection(str))
? ? ? ? ? ? {
? ? ? ? ? ? ? ? //执行
? ? ? ? ? ? ? ? SqlCommand cmd = new SqlCommand();
? ? ? ? ? ? ? ? PrepareSQLCommand(cmdType, sql, parms, con, cmd);
? ? ? ? ? ? ? ? result = (int)cmd.ExecuteScalar();
? ? ? ? ? ? ? ? return result;
? ? ? ? ? ? }
? ? ? ? }
? ? }
}
?
?
?
--创建用户信息表
create database test;
create table log4j
(
id int identity(1,1) not null primary key,?
stamp varchar(10)not null, ? ?
thread varchar(30)not null, ? ? ?
clazz varchar(15)not null,
infoLevel varchar(15)not null,
message varchar(250)?
)
insert ?into log4j values('dddddd','aaaaa','dsfdfsfs','fdsffas');
create table ?tb_charts
(
?team varchar(50),
?Points varchar(50)
)?
insert into tb_charts values('Java','33');
insert into tb_charts values('C++','33');
insert into tb_charts values('Android','33');
insert into tb_charts values('PHP','33');
insert into tb_charts values('C#,ASP.NET','33');
insert into tb_charts values('Oracle','33');
insert into tb_charts values('F','33');
select * from tb_charts;
?
?
?
?
?
?
?
??
?
?
源代码:http://download.csdn.net/detail/l_ji_l/4336918