Posts

Showing posts with the label Database

How to select data from another sql server

We have a target to run a JOB on server to import data from another SQL server instance. For example take Server 1 - Main Server 2 - From which we have to import. If you have admin rights on both the servers you can "Link the servers" under "Server Objects>>Linked Servers" Right click on the same and provide all the parameters of server or as an alternate you can run following command. EXEC sp_addlinkedserver @server = 'db1', @srvproduct = 'SQLServer OLEDB Provider',  @provider = 'SQLOLEDB',  @datasrc = 'server2',  @provstr='User Id=sa; Password=abc' The above command parameters:-  @server- An identification name of server. @datasrc- Your server instance name or IP. Your SQL will look like:- Select * from db1.dbname.dbo.tablename If sometimes the server will get changed, the above statement gives you the option to change the user name, password and server at any points of time without effecting the ...

How to set max limt of File Upload in Asp.net

Many times I faced the same problem with all my applications, that is Max size of file to be uploaded to server. By default, the maximum size limit of a file to be uploaded to a server using the ASP.NET FileUpload control is 4MB. You cannot upload anything that is larger than this limit. If you wants to upload a file more the size of 4 MB which is by default, you have to make some changes in the application's web.config: <configuration> <system.web> <httpRuntime maxRequestLength="xxx" /> </system.web> </configuration> Below is the small description of the parameters attributes. maxRequestLength - Attribute limits the file upload size for ASP.NET application. This limit can be used to prevent denial of service attacks (DOS) caused by users posting large files to the server. The size specified is in kilobytes. As mentioned earlier, the default is "4096" (4 MB). Max value is "1048576" (1 GB) for .NET Framework ...

How to get tables names in MySql (sysobjects in sql server)

In Sql server we have a table sysobjects which holds names of all the tables i.e. system and user tables. Like the same we have command “Show tables” which show all the tables of specified database. Syntax Show Tables from <databasename> Here is an example. SHOW TABLES FROM MySql If you had already select a database you can only use Show tables to show all the tables in the database. For ex. Select database MySql and in Sql command window enter following text SHOW TABLES And click on Run. It will show all the tables which is avalible in the list

How to take back up of my sql database using C#

Image
You can also download running code. Taking a back up of my sql using C# is very easy but this also be termed as tricky backup. Like Sql server my sql does not provide built in stored procedures to take back up. For back up my sql use a Exe file named “mysqldump.exe” You will find this Exe file in “C:\Program Files\MySQL\MySQL Server 5.0\bin” folder of mySql. This file takes so many parameters for different options. But my task is to simply take a backup of single database To take a backup of single database following are the parameters mysqldump -u<usernane> -p <password> -h<servername or ip> <databasename> > <localtion to take backup> Please let me know if this helps you to perform your task easily.

Auto Complete Example in Asp.net C# Using JQuery

Image
Download Running Code Supporting JQuery Before writing this post I had written one another post which is using a pure JavaScript to show Auto complete or Auto delete example. My previous example is not using Jquery which is a famous and reliable way to present your data. One of the drawback of my previous example is it will become slow as I have to load a bulk data for auto complete box. I had received many comments on this post, some of them had appreciated and some of them had suggested using Jquery. One of my great readers had given an example of Jquey which I am posting to help you all. So, before posting this example I would like to say thanks to my reader Eng. Mohammed Ibrahim who had suggested and helped me to help others.

How to use Enterprise Library using C#

Summary The Microsoft Enterprise Library is a collection of reusable software components (application blocks) designed to assist software developers with common enterprise development cross-cutting concerns (such as logging, validation, data access, exception handling, and many others). Application blocks are a type of guidance; they are provided as source code, test cases, and documentation that can be used "as is," extended, or modified by developers to use on complex, enterprise-level line-of-business development projects. Some Features While using enterprise library you have to concern about opening and closing connections. This will automatically handle connection pooling and other important errors of connection and database. I had used Enterprise Library 2.0 - January 2006. To use Enterprise Library you required to add reference of following files:- Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Configuration.De...

Cluster and Non Cluster indexes

When I first started using SQL Server as a novice, I was initially confused as to the differences between clustered and non-clustered indexes. As a developer, and new DBA, I took it upon myself to learn everything I could about these index types, and when they should be used. This article is a result of my learning and experience, and explains the differences between clustered and non-clustered index data structures for the DBA or developer new to SQL Server. If you are new to SQL Server, I hope you find this article useful. As you read this article, if you choose, you can cut and paste the code I have provided in order to more fully understand and appreciate the differences between clustered and non-clustered indexes. Part I: Non-Clustered Index Creating a Table To better explain SQL Server non-clustered indexes; let’s start by creating a new table and populating it with some sample data using the following scripts. I assume you have a database you can use for this. If not, you will w...

Randomly Sort Sql server Table

You can sort a Table Randomly with a single keyword. the newsid() is the keyword which generates a random number in sql server. Here is small ex. 1)Create a database 2)Create Table Master 3)Create Fields Code nvarchar(50), Name Nvarchar(50) 4)Enter some data into table 5)Now open new query window 6)Write sql 7) Select * from Master Order by newid() Now, run this code it will return data in random format. You can also use newid() to generate a unique number or a number like verification code etc. for ex. Select newid()

Sort Datatable randomly

This is not possible to Sort a Datatable directly. In order to randomize the rows in a DataTable, do the following: 1) Add a random number DataColumn to the DataTable 2) For each row, generate a random number and store it to the new column 3) Create a DataView and sort by the random number DataColumn Test this by simple ex. DataTable dt = GetData(); dt.Columns.Add(new DataColumn("RandomNum", Type.GetType("System.Int32"))); Random random = new Random(); for (int i = 0; i { dt.Rows[i]["RandNum"] = random.Next(1000); } DataView dv = new DataView(dt); dv.Sort = "RandomNum";

How to use Hindi fonts on Website

Now in current world the importance of multi lingual websites has increased. People demands for sites in different languages for different uses. I have a site on which I have to show data in Hindi. This had become a major issue while development. I had searched the internet and found a solution named Microsoft WEFT. I was very happy to find a solution. I start working on the basis of this software. But after successful launch of website the use had found an major issue. The .eot files are only supported on IE browsers. Now, this is the time to work like a machine to search for a true solution. I have searched many sites. But, finally god give me the solution by giving me the concept of UNICODE fonts Here is the example how to use UNICODE fonts. use these sites to make entry in hindi http://utopianvision.co.uk/hindi/write/ http://www.geocities.com/matthewblackwell/hindiEditor.html You can make entry in hindi for ex. on this http://utopianvision.co.uk/hindi/write/ in second text box ente...