Click here to Skip to main content
Click here to Skip to main content
Articles » Database » Database » General » Downloads
 
Add your own
alternative version

Universal Database Admin for ASP.NET and SQL Server (Reloaded)

, 15 Apr 2006
A dynamic web application needs an admin section for CRUD actions on the records/tables in the database. Wouldn't it be nice to have a database admin, which can be plugged to any web application? Just give your SQL connection string and it dynamically manages all table operations in just five pages.
admin.zip
Admin
Admin.csproj.webinfo
bin
Admin.dll
classes
Global.asax
images
Admin.gif
admindb.jpg
admindetails.jpg
CreateTable.jpg
custom.jpg
dataAccess.jpg
Delete.jpg
DeleteTable.JPG
Edit.jpg
Editfield.jpg
InAction.jpg
login.jpg
placeholder-100.jpg
placeholder-200.jpg
placeholder-600.jpg
readtable.jpg
TableDetails.jpg
Tables.jpg
View.jpg
includes
screen1.bmp
SQLI.jpg
admin2005.zip
Admin2005
App_Code
ClassDiagram.cd
classes
Migrated
bin
Admin.dll
classes
Global.asax
images
Admin.gif
admindb.jpg
admindetails.jpg
CreateTable.jpg
custom.jpg
dataAccess.jpg
Delete.jpg
DeleteTable.JPG
Edit.jpg
Editfield.jpg
InAction.jpg
login.jpg
placeholder-100.jpg
placeholder-200.jpg
placeholder-600.jpg
readtable.jpg
TableDetails.jpg
Tables.jpg
View.jpg
includes
screen1.bmp
SQLI.jpg
adminlite.zip
AdminLite
AdminLite.csproj.webinfo
bin
AdminLite.dll
classes
Global.asax
images
Admin.gif
admindb.jpg
admindetails.jpg
clear.gif
CreateTable.jpg
custom.jpg
dataAccess.jpg
Delete.jpg
deleterow.gif
DeleteTable.JPG
edit.gif
Edit.jpg
Editfield.jpg
InAction.jpg
Login.jpg
placeholder-100.jpg
placeholder-200.jpg
placeholder-600.jpg
readtable.jpg
TableDetails.JPG
tables.jpg
View.jpg
includes
admin_src.zip
Admin_Src
Admin.csproj.webinfo
bin
Admin.dll
Admin.pdb
Global.asax
images
Admin.gif
admindb.jpg
admindetails.jpg
dataAccess.jpg
Delete.jpg
Edit.jpg
InAction.jpg
Login.jpg
TableDetails.JPG
tables.jpg
View.jpg
includes
dbadmin_src.zip
dbadmin
images
add.gif
btn_check_update.gif
btn_databases.gif
btn_dbadmin_hp.gif
btn_ftquery.gif
btn_home.gif
btn_procedures.gif
btn_relations.gif
btn_stpworks.gif
btn_tables.gif
btn_views.gif
check.gif
cycle.gif
DBAdmin_logo.gif
delete.gif
edit.gif
excel.gif
folder.gif
ftquery.gif
icon_hide.gif
icon_logoff.gif
icon_settings.gif
icon_show.gif
icon_submit_bug.gif
key.gif
link.gif
linked.gif
logo.jpg
msaccess.gif
query.gif
refresh.gif
rename.gif
run.gif
spacer.gif
structure.gif
table.gif
tables.gif
table_shadow_bottom.gif
table_shadow_corner.gif
table_shadow_right.gif
table_title_center.gif
table_title_left.gif
table_title_right.gif
un_key.gif
view.gif
xml.gif
languages
dbadmin_en.lang
plugins
htmleditor
aleft.gif
aright.gif
blist.gif
bold.gif
center.gif
copy.gif
cut.gif
delete.gif
help.gif
ileft.gif
image.gif
instable.gif
iright.gif
italic.gif
nlist.gif
parea.gif
paste.gif
redo.gif
tbdown.gif
tpaint.gif
under.gif
undo.gif
wlink.gif
scripts
//*****************************************************************************************************************
//Class name : clsDataAccess 
//Defination : This class is the most important class as it does all the updating,Inserting,deleting,Retrieving
//part in the database.The methods in this class is called by all the other methods in other classes.Connection
//with the database is set up here only.We have used Granth SQL database.We added this class after our analysis
//phase.As you will go through the code we have not used any attributes in any class the only thing we have used is
//a query and nothing else. 
//Date Added : 11/11/05
//Please keep the comments if you distribute
//Author :        Quartz (Rajesh Lal - connectrajesh@hotmail.com)
//*****************************************************************************************************************

using System;
using System.Configuration;
using System.Data;
using System.Data.Common ;
using System.Data.SqlClient; 
namespace Admin
{
	public class clsDataAccess // Class defination
	{
		public clsDataAccess()
		{	}
		SqlConnection mycon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);  
 		// SqlConnection mycon = new SqlConnection("Data Source=198.87.87.6;POOLING=FALSE;database=exactorder;User ID=exactorder;Password=exactorder");
		//private string query;
		
		public bool openConnection() // Opens database connection with Granth in SQL SERVER
		{
				mycon.Open();
 		return true;
		}
		public void closeConnection() // Closes database connection with Granth in SQL SERVER
		{

		mycon.Close(); 
		mycon = null;
		}
		public SqlDataReader getData(string query) // Getdata from the table required(given in query)in datareader
		{
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			SqlDataReader myr = sqlCommand.ExecuteReader(CommandBehavior.CloseConnection);
            return myr;
			 
		}
		public void saveData(string query) // Save data usually,inserts and updates the data in table given in query
		{
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			sqlCommand.ExecuteNonQuery();
			sqlCommand.Dispose();  
			
		}
		public bool saveNewData(string query) // Save data usually,inserts and updates the data in table given in query
		{
			bool stat = false;
			try
			{
				SqlCommand sqlCommand = new SqlCommand();
				sqlCommand.CommandText= query;
				sqlCommand.Connection=mycon;
				sqlCommand.ExecuteNonQuery();
				sqlCommand.Dispose();  
				stat = true;
			}
			catch
			{
				stat=false;
			}
			return stat;
			
		}
		
		public int DeleteData(string query) // Delete data in database depending on the tablename given in query.
		{
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			return sqlCommand.ExecuteNonQuery();
			
		}
		public SqlDataAdapter getDataforUpdate(string query) // Get data by paging using datagrid which returns the dataset in datagris
		{
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query,mycon);
			DataSet dataSet = new DataSet();
			//sqlDataAdapter.Fill(dataSet,"NewData");
			return sqlDataAdapter;
		}
		public DataSet getDatabyPaging(string query) // Get data by paging using datagrid which returns the dataset in datagris
		{
			SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(query,mycon);
			DataSet dataSet = new DataSet();
			sqlDataAdapter.Fill(dataSet);
			return dataSet;
			
		}
		public int getCheck(string query) // check a particular value to see the validity of mediaid and userid.This method is called in media and user class.
		{
			int i;
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			i = Convert.ToInt32(sqlCommand.ExecuteScalar());
			return i;
		}
		public string getValue(string query,int j) // Get a value of limit from the database table Employees to check before issuing media.
		{
			string i ="0";
			
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			SqlDataReader myReader = sqlCommand.ExecuteReader();
			
			if( myReader.Read()==true)
			{
				
				i=myReader.GetValue(j).ToString();
				
			}
			return i;
		}
		
		public SqlDataReader Login(string query)//Log in method for LA and Client.
		{
			clsDataAccess myclass = new clsDataAccess();
			myclass.openConnection();
			SqlDataReader dr = myclass.getData(query); //Class Data Access is called here
			return dr; 	
		}
		public DataTable getTablenames()
		{
			SqlDataAdapter da = new SqlDataAdapter("SELECT * FROM Information_Schema.Tables where Table_Type = 'BASE TABLE'", mycon);
			DataTable dt = new DataTable();
			da.Fill(dt);
			return dt;

		}

		public int TableWrite(string query) 
		{
			SqlCommand sqlCommand = new SqlCommand();
			sqlCommand.CommandText= query;
			sqlCommand.Connection=mycon;
			return sqlCommand.ExecuteNonQuery();
		}



	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author


| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 15 Apr 2006
Article Copyright 2005 by Raj Lal
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid