ͨÓõÄSqlServer²Ù¿ØÀà
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
public class CommandInfo
{
public string CommandText;
public SqlParameter[] Parameters;
}
/// <summary>
/// Êý¾Ý·ÃÎʳéÏó»ù´¡Àà
/// </summary>
public abstract class DbHelperSQL
{
//Êý¾Ý¿âÁ¬½Ó×Ö·û´®(web.configÀ´ÅäÖÃ)£¬¿ÉÒÔ¶¯Ì¬¸ü¸ÄconnectionStringÖ§³Ö¶àÊý¾Ý¿â.
public static string connectionString = ConfigurationManager.ConnectionStrings["cnpg_newsConStr"].ToString();
public DbHelperSQL()
{
}
#region ¹«Ó÷½·¨
public static int GetMaxID(string FieldName, string TableName)
{
string strsql = "select max(" + FieldName + ")+1 from " + TableName;
object obj = DbHelperSQL.GetSingle(strsql);
if (obj == null)
{
return 1;
}
else
{
return int.Parse(obj.ToString());
}
}
public static bool Exists(string strSql)
{
object obj = DbHelperSQL.GetSingle(strSql);
int cmdresult;
if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value)))
{
cmdresult = 0;
}
else
{
cmdresult = int.Parse(obj.ToString());
}
if (cmdresult == 0)
{
return false;
}
else
{
return true;
}
}
/// <summary>
/// ±íÊÇ·ñ´æÔÚ
/// </summary>
/// <param name="TableName"></param>
/// <returns></returns>
public stati
Ïà¹ØÎĵµ£º
SQL Serverµ¼³ö±íµ½EXCELÎļþµÄ´æ´¢¹ý³Ì:
¡¡¡¡*--Êý¾Ýµ¼³öEXCEL
¡¡¡¡µ¼³ö±íÖеÄÊý¾Ýµ½Excel,°üº¬×Ö¶ÎÃû,ÎļþÎªÕæÕýµÄExcelÎļþ
¡¡¡¡,Èç¹ûÎļþ²»´æÔÚ,½«×Ô¶¯´´½¨Îļþ
¡¡¡¡,Èç¹û±í²»´æÔÚ,½«×Ô¶¯´´½¨±í
¡¡¡¡»ùÓÚͨÓÃÐÔ¿¼ÂÇ,½öÖ§³Öµ¼³ö±ê×¼Êý¾ÝÀàÐÍ
¡¡¡¡---*/
¡¡¡¡/**//*--µ÷ÓÃʾÀý
¡¡¡¡p_exporttb @tbname='µØÇø ......
1¡¢´´½¨Êý¾Ý¿âtestdb
2¡¢´´½¨±ítest
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[test](
[id] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
[name] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
[sex] [bit] NULL
) ON [PRIMARY]
3¡¢´´½¨Êý¾Ý¿âdb
......
ÊÂÎñµÄ¹¦ÄÜÔÚsqlserverÖÐÓÉÀ´ÒѾã¬ÒòΪ×î½üÔÚ×öÒ»¸öÊý¾Ýͬ²½·½°¸£¬ËùÒÔÓлú»áÔÙ´ÎÑо¿Ò»ÏÂËüÒÔ¼°¿ìÕյȣ¬·¢ÏÖ»¹ÊÇÓкܶ಻´íµÄ¹¦Äܺ͸ĽøµÄ¡£ÕâÀïÒÔsqlserver2008µÄÊÂÎñ·¢²¼¹¦ÄÜΪÀý£¬¶Ô·¢²¼¶©Ôĵķ½Ê½¼òÒª½éÉÜһϲÙ×÷Á÷³Ì£¬Ò»·½Ãæ×ö¸ö×ܽᱸ·Ý£¬Ò»·½ÃæÓë´ó¼Ò½øÐÐһϷÖÏíºÍ½»Á÷¡£·Ñ»°¾Í² ......
create database db
use db
go
create table course
(
sno varchar(20),
cno int ,
Gmark int
)
insert into course values('20071513115',1,80)
insert into course values('20071513114',2,80)
insert into course values('20071513113',3,80)
insert into course values('20071513 ......