বৃহস্পতিবার, ৭ এপ্রিল, ২০১১

SQL Database File Attach command

USE master;
GO
CREATE DATABASE MyDatabase 
    ON (FILENAME = 'C:\MySQLServer\Mydata_Data.mdf'),
    (FILENAME = 'C:\MySQLServer\Mydata_Log.ldf')
    FOR ATTACH;
GO

SQL Database Backup And restore command

BACKUP COMMAND
BACKUP DATABASE  [DbName] TO DISK='C:\Db.BAK';

 RESTORE COMMAND
RESTORE DATABASE [DbName] FROM DISK = N'C:\Db.BAK' WITH FILE = 1, MOVE N'DbName_dat' TO N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\DbName_data.mdf', MOVE N'DbName_log' TO N'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\DbName_log.ldf', NOUNLOAD, REPLACE, STATS = 10
GO

Month number to Month String Convert in c sharp

 private static string GetMonthName(int month, bool test)
       {

           DateTime date = new DateTime(1900, month, 1);

           if (test)
          {
              return date.ToString("MMM");
          }
         else
        {
           return date.ToString("MMMM");
        }
    }

সোমবার, ৪ এপ্রিল, ২০১১

File read and Write in C#

 File Write in C#
 StreamWriter writer = new StreamWriter("Filename.txt");
  writer.WriteLine("some string");
   writer.Close();

File Read in C#
 StreamReader reader = new StreamReader("Filename.txt");
 string text= reader.ReadLine();          
 reader.Close();