Sunday, 11 November 2018
Wednesday, 31 October 2018
Tuesday, 30 October 2018
Saturday, 27 October 2018
Tuesday, 16 October 2018
Sunday, 14 October 2018
Thursday, 11 October 2018
Saturday, 6 October 2018
Monday, 10 September 2018
Saturday, 8 September 2018
Backup sql server database in c# button click. code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BackupDBSoft
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime d = DateTime.Now;
string dd = d.Day + "-" + d.Month;
string servname = textBox1.Text;
string dbname = textBox2.Text;// database name
string aaa = @"Data Source=" + servname + ";Integrated Security=True;Initial Catalog=" + dbname + "";
SqlConnection con = new SqlConnection(aaa);
//con.ConnectionString = ConfigurationManager.ConnectionStrings["BackupCatalogDBSoft.Properties.Settings."+dbname+"ConnectionString"].ToString();
con.Open();
string str = "USE " + dbname + ";";
string str1 = "BACKUP DATABASE " + dbname +
" TO DISK = 'D:\\Database\\" + dbname + "_" + dd +
".Bak' WITH FORMAT,MEDIANAME = 'Z_SQLServerBackups',NAME = 'Full Backup of " + dbname + "';";
SqlCommand cmd1 = new SqlCommand(str, con);
SqlCommand cmd2 = new SqlCommand(str1, con);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
MessageBox.Show("Successfully Completed Backup. You can find this file (DB Name.Bak) in your Disk D:\\.... never edit this file name.");
con.Close();
//this.Close();
}
}
}
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BackupDBSoft
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DateTime d = DateTime.Now;
string dd = d.Day + "-" + d.Month;
string servname = textBox1.Text;
string dbname = textBox2.Text;// database name
string aaa = @"Data Source=" + servname + ";Integrated Security=True;Initial Catalog=" + dbname + "";
SqlConnection con = new SqlConnection(aaa);
//con.ConnectionString = ConfigurationManager.ConnectionStrings["BackupCatalogDBSoft.Properties.Settings."+dbname+"ConnectionString"].ToString();
con.Open();
string str = "USE " + dbname + ";";
string str1 = "BACKUP DATABASE " + dbname +
" TO DISK = 'D:\\Database\\" + dbname + "_" + dd +
".Bak' WITH FORMAT,MEDIANAME = 'Z_SQLServerBackups',NAME = 'Full Backup of " + dbname + "';";
SqlCommand cmd1 = new SqlCommand(str, con);
SqlCommand cmd2 = new SqlCommand(str1, con);
cmd1.ExecuteNonQuery();
cmd2.ExecuteNonQuery();
MessageBox.Show("Successfully Completed Backup. You can find this file (DB Name.Bak) in your Disk D:\\.... never edit this file name.");
con.Close();
//this.Close();
}
}
}
Monday, 20 August 2018
Saturday, 11 August 2018
Sunday, 22 July 2018
Thursday, 5 July 2018
Thursday, 21 June 2018
Function of Number to words in RDLC Report
Number to words in RDLC Report
https://www.youtube.com/watch?v=ScOQO8iJR3g
Function Start From Below
Public Shared Function changeToWords(ByVal numb As [String]) As [String]
Dim val As [String] = "", wholeNo As [String] = numb, points As [String] = "", andStr As [String] = "", pointStr As [String] = ""
Dim endStr As [String] = ""
Try
Dim decimalPlace As Integer = numb.IndexOf(".")
If decimalPlace > 0 Then
wholeNo = numb.Substring(0, decimalPlace)
points = numb.Substring(decimalPlace + 1)
If Convert.ToInt32(points) > 0 Then
andStr = "point"
' just to separate whole numbers from points
pointStr = translateCents(points)
End If
End If
val = [String].Format("{0} {1}{2} {3}", translateWholeNumber(wholeNo).Trim(), andStr, pointStr, endStr)
Catch
End Try
Return val
End Function
Private Shared Function translateWholeNumber(ByVal number As [String]) As [String]
Dim word As String = ""
Try
Dim beginsZero As Boolean = False
'tests for 0XX
Dim isDone As Boolean = False
'test if already translated
Dim dblAmt As Double = (Convert.ToDouble(number))
'if ((dblAmt > 0) && number.StartsWith("0"))
If dblAmt > 0 Then
'test for zero or digit zero in a nuemric
beginsZero = number.StartsWith("0")
Dim numDigits As Integer = number.Length
Dim pos As Integer = 0
'store digit grouping
Dim place As [String] = ""
'digit grouping name:hundres,thousand,etc...
Select Case numDigits
Case 1
'ones' range
word = ones(number)
isDone = True
Exit Select
Case 2
'tens' range
word = tens(number)
isDone = True
Exit Select
Case 3
'hundreds' range
pos = (numDigits Mod 3) + 1
place = " Hundred "
Exit Select
'thousands' range
Case 4, 5, 6
pos = (numDigits Mod 4) + 1
place = " Thousand "
Exit Select
'millions' range
Case 7, 8, 9
pos = (numDigits Mod 7) + 1
place = " Million "
Exit Select
Case 10
'Billions's range
pos = (numDigits Mod 10) + 1
place = " Billion "
Exit Select
Case Else
'add extra case options for anything above Billion...
isDone = True
Exit Select
End Select
If Not isDone Then
'if transalation is not done, continue...(Recursion comes in now!!)
word = translateWholeNumber(number.Substring(0, pos)) + place + translateWholeNumber(number.Substring(pos))
'check for trailing zeros
If beginsZero Then
word = " and " & word.Trim()
End If
End If
'ignore digit grouping names
If word.Trim().Equals(place.Trim()) Then
word = ""
End If
End If
Catch
End Try
Return word.Trim()
End Function
Private Shared Function tens(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = Nothing
Select Case digt
Case 10
name = "Ten"
Exit Select
Case 11
name = "Eleven"
Exit Select
Case 12
name = "Twelve"
Exit Select
Case 13
name = "Thirteen"
Exit Select
Case 14
name = "Fourteen"
Exit Select
Case 15
name = "Fifteen"
Exit Select
Case 16
name = "Sixteen"
Exit Select
Case 17
name = "Seventeen"
Exit Select
Case 18
name = "Eighteen"
Exit Select
Case 19
name = "Nineteen"
Exit Select
Case 20
name = "Twenty"
Exit Select
Case 30
name = "Thirty"
Exit Select
Case 40
name = "Fourty"
Exit Select
Case 50
name = "Fifty"
Exit Select
Case 60
name = "Sixty"
Exit Select
Case 70
name = "Seventy"
Exit Select
Case 80
name = "Eighty"
Exit Select
Case 90
name = "Ninety"
Exit Select
Case Else
If digt > 0 Then
name = (tens(digit.Substring(0, 1) & "0") & " ") + ones(digit.Substring(1))
End If
Exit Select
End Select
Return name
End Function
Private Shared Function ones(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = ""
Select Case digt
Case 1
name = "One"
Exit Select
Case 2
name = "Two"
Exit Select
Case 3
name = "Three"
Exit Select
Case 4
name = "Four"
Exit Select
Case 5
name = "Five"
Exit Select
Case 6
name = "Six"
Exit Select
Case 7
name = "Seven"
Exit Select
Case 8
name = "Eight"
Exit Select
Case 9
name = "Nine"
Exit Select
End Select
Return name
End Function
Private Shared Function translateCents(ByVal cents As [String]) As [String]
Dim cts As [String] = "", digit As [String] = "", engOne As [String] = ""
For i As Integer = 0 To cents.Length - 1
digit = cents(i).ToString()
If digit.Equals("0") Then
engOne = "Zero"
Else
engOne = ones(digit)
End If
cts += " " & engOne
Next
Return cts
End Function
https://www.youtube.com/watch?v=ScOQO8iJR3g
Function Start From Below
Public Shared Function changeToWords(ByVal numb As [String]) As [String]
Dim val As [String] = "", wholeNo As [String] = numb, points As [String] = "", andStr As [String] = "", pointStr As [String] = ""
Dim endStr As [String] = ""
Try
Dim decimalPlace As Integer = numb.IndexOf(".")
If decimalPlace > 0 Then
wholeNo = numb.Substring(0, decimalPlace)
points = numb.Substring(decimalPlace + 1)
If Convert.ToInt32(points) > 0 Then
andStr = "point"
' just to separate whole numbers from points
pointStr = translateCents(points)
End If
End If
val = [String].Format("{0} {1}{2} {3}", translateWholeNumber(wholeNo).Trim(), andStr, pointStr, endStr)
Catch
End Try
Return val
End Function
Private Shared Function translateWholeNumber(ByVal number As [String]) As [String]
Dim word As String = ""
Try
Dim beginsZero As Boolean = False
'tests for 0XX
Dim isDone As Boolean = False
'test if already translated
Dim dblAmt As Double = (Convert.ToDouble(number))
'if ((dblAmt > 0) && number.StartsWith("0"))
If dblAmt > 0 Then
'test for zero or digit zero in a nuemric
beginsZero = number.StartsWith("0")
Dim numDigits As Integer = number.Length
Dim pos As Integer = 0
'store digit grouping
Dim place As [String] = ""
'digit grouping name:hundres,thousand,etc...
Select Case numDigits
Case 1
'ones' range
word = ones(number)
isDone = True
Exit Select
Case 2
'tens' range
word = tens(number)
isDone = True
Exit Select
Case 3
'hundreds' range
pos = (numDigits Mod 3) + 1
place = " Hundred "
Exit Select
'thousands' range
Case 4, 5, 6
pos = (numDigits Mod 4) + 1
place = " Thousand "
Exit Select
'millions' range
Case 7, 8, 9
pos = (numDigits Mod 7) + 1
place = " Million "
Exit Select
Case 10
'Billions's range
pos = (numDigits Mod 10) + 1
place = " Billion "
Exit Select
Case Else
'add extra case options for anything above Billion...
isDone = True
Exit Select
End Select
If Not isDone Then
'if transalation is not done, continue...(Recursion comes in now!!)
word = translateWholeNumber(number.Substring(0, pos)) + place + translateWholeNumber(number.Substring(pos))
'check for trailing zeros
If beginsZero Then
word = " and " & word.Trim()
End If
End If
'ignore digit grouping names
If word.Trim().Equals(place.Trim()) Then
word = ""
End If
End If
Catch
End Try
Return word.Trim()
End Function
Private Shared Function tens(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = Nothing
Select Case digt
Case 10
name = "Ten"
Exit Select
Case 11
name = "Eleven"
Exit Select
Case 12
name = "Twelve"
Exit Select
Case 13
name = "Thirteen"
Exit Select
Case 14
name = "Fourteen"
Exit Select
Case 15
name = "Fifteen"
Exit Select
Case 16
name = "Sixteen"
Exit Select
Case 17
name = "Seventeen"
Exit Select
Case 18
name = "Eighteen"
Exit Select
Case 19
name = "Nineteen"
Exit Select
Case 20
name = "Twenty"
Exit Select
Case 30
name = "Thirty"
Exit Select
Case 40
name = "Fourty"
Exit Select
Case 50
name = "Fifty"
Exit Select
Case 60
name = "Sixty"
Exit Select
Case 70
name = "Seventy"
Exit Select
Case 80
name = "Eighty"
Exit Select
Case 90
name = "Ninety"
Exit Select
Case Else
If digt > 0 Then
name = (tens(digit.Substring(0, 1) & "0") & " ") + ones(digit.Substring(1))
End If
Exit Select
End Select
Return name
End Function
Private Shared Function ones(ByVal digit As [String]) As [String]
Dim digt As Integer = Convert.ToInt32(digit)
Dim name As [String] = ""
Select Case digt
Case 1
name = "One"
Exit Select
Case 2
name = "Two"
Exit Select
Case 3
name = "Three"
Exit Select
Case 4
name = "Four"
Exit Select
Case 5
name = "Five"
Exit Select
Case 6
name = "Six"
Exit Select
Case 7
name = "Seven"
Exit Select
Case 8
name = "Eight"
Exit Select
Case 9
name = "Nine"
Exit Select
End Select
Return name
End Function
Private Shared Function translateCents(ByVal cents As [String]) As [String]
Dim cts As [String] = "", digit As [String] = "", engOne As [String] = ""
For i As Integer = 0 To cents.Length - 1
digit = cents(i).ToString()
If digit.Equals("0") Then
engOne = "Zero"
Else
engOne = ones(digit)
End If
cts += " " & engOne
Next
Return cts
End Function
Saturday, 9 June 2018
Thursday, 7 June 2018
Thursday, 31 May 2018
Tuesday, 29 May 2018
Tuesday, 22 May 2018
Thursday, 26 April 2018
Tuesday, 17 April 2018
Monday, 16 April 2018
Wednesday, 11 April 2018
Thursday, 5 April 2018
Sunday, 1 April 2018
Saturday, 31 March 2018
Wednesday, 21 March 2018
Monday, 19 March 2018
Sunday, 18 March 2018
Saturday, 17 March 2018
Thursday, 15 March 2018
Sunday, 4 March 2018
Wednesday, 28 February 2018
Sunday, 25 February 2018
Sunday, 18 February 2018
Wednesday, 14 February 2018
Sunday, 11 February 2018
Wednesday, 24 January 2018
Tuesday, 23 January 2018
Subscribe to:
Posts (Atom)