if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[tsvobject]') and objectproperty(id, n'isusertable') = 1) drop table [dbo].[tsvobject] go
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[tsvrole]') and objectproperty(id, n'isusertable') = 1) drop table [dbo].[tsvrole] go
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[tsvroleobject]') and objectproperty(id, n'isusertable') = 1) drop table [dbo].[tsvroleobject] go
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[tsvroleuser]') and objectproperty(id, n'isusertable') = 1) drop table [dbo].[tsvroleuser] go
if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[tsvuser]') and objectproperty(id, n'isusertable') = 1) drop table [dbo].[tsvuser] go
create table [dbo].[tsvobject] ( [fobjectid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [fobjectname] [varchar] (50) collate sql_latin1_general_cp1_ci_as not null ) on [primary] go
create table [dbo].[tsvrole] ( [froleid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [frolename] [varchar] (50) collate sql_latin1_general_cp1_ci_as not null ) on [primary] go
create table [dbo].[tsvroleobject] ( [froleid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [fobjectid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [fvisible] [bit] not null , [fenable] [bit] not null , [fexecutable] [bit] not null ) on [primary] go
create table [dbo].[tsvroleuser] ( [froleid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [fuserid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null ) on [primary] go
create table [dbo].[tsvuser] ( [fuserid] [varchar] (30) collate sql_latin1_general_cp1_ci_as not null , [fusername] [varchar] (50) collate sql_latin1_general_cp1_ci_as not null , [fuserpwd] [nvarchar] (20) collate sql_latin1_general_cp1_ci_as not null , [fuseremail] [varchar] (30) collate sql_latin1_general_cp1_ci_as null ) on [primary] go
alter table [dbo].[tsvobject] with nocheck add constraint [pk_tsvobject] primary key clustered ( [fobjectid] ) on [primary] go
alter table [dbo].[tsvrole] with nocheck add constraint [pk_tsvprjrole] primary key clustered ( [froleid] ) on [primary] go
alter table [dbo].[tsvroleobject] with nocheck add constraint [df_tsvroleobject_fvisible] default (0) for [fvisible], constraint [df_tsvroleobject_fenabled] default (0) for [fenable], constraint [df_tsvroleobject_fexecutable] default (0) for [fexecutable], constraint [pk_tsvroleobject] primary key clustered ( [froleid], [fobjectid] ) on [primary] go
alter table [dbo].[tsvroleuser] with nocheck add constraint [pk_tsvroleuser] primary key clustered ( [froleid], [fuserid] ) on [primary] go
alter table [dbo].[tsvuser] with nocheck add constraint [pk_tsvprjuser] primary key clustered ( [fuserid] ) on [primary] go
2、在程序中读取数据,函数是:
static public dataset getadmindata(string strdatabaseconnectionstring) { dataset ds;
sqlconnection sqlconnection = new sqlconnection(); sqlcommand sqlcommand = new sqlcommand();
其中调用的stored procedure是: if exists (select * from dbo.sysobjects where id = object_id(n'[dbo].[spsvadmindata]') and objectproperty(id, n'isprocedure') = 1) drop procedure [dbo].[spsvadmindata] go
set quoted_identifier on go set ansi_nulls off go
create procedure dbo.spsvadmindata as
select froleid, frolename from tsvrole order by froleid
select fuserid, fusername, fuseremail from tsvuser order by fuserid
select fobjectid, fobjectname from tsvobject order by fobjectid
select froleid, fuserid from tsvroleuser order by froleid, fuserid
select froleid, fobjectid, fvisible, fenable, fexecutable from tsvroleobject order by froleid, fobjectid go set quoted_identifier off go set ansi_nulls on go