Thursday, November 29, 2012

How to take backup of database using mysql command line

Taking backup from mysql command Line is quite simple .Just follow following steps and its done.

1)Open command prompt(run as administrator).
2)Move to the bin directory of mysql server.
3) Type following command
mysqldump -u root -p [your password] [database name for backup] -r ["filename"]
4)Dont forget to add double quotes for file name.

Note:If you dont specify path of file ,then it will go in default directory(Programfiles\Mysql\mysqlserver5.\bin).

Monday, November 26, 2012

Ajax Autocomplete

  To get autocomplete in textbox just drag a textbox to a form



Add toolkitscriptmanager.Then click on smart tag and select "Add Auto complete page method".


Now in Getcompletion list function add code for getting data from database.


 <System.Web.Services.WebMethodAttribute()> <System.Web.Script.Services.ScriptMethodAttribute()>
    Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
        Dim names As New ArrayList
        Dim db As New dataBase
        db.dbOpenConnection()
        Dim query As String = "Select username from test "
        db.cmd.CommandText = query
        Dim dr As OdbcDataReader
        dr = db.cmd.ExecuteReader
        While dr.Read()
            names.Add(dr("username").ToString())
        End While
        db.dbCloseConnection()


        Return (
            From m As String In names
            Where m.StartsWith(prefixText, StringComparison.CurrentCultureIgnoreCase)
            Select m).Take(count).ToArray()
    End Function



You can add styles to autocomplete

 <style>
For list shown
   .AutoExtender
        {
            font-family: Verdana, Helvetica, sans-serif;
            font-size: .8em;
            font-weight: normal;
            border: solid 1px #006699;
            line-height: 20px;
            padding: 10px;
            background-color: White;
            margin-left:10px;
        }
        .AutoExtenderList
        {
            border-bottom: dotted 1px #006699;
            cursor: pointer;
            color: Maroon;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            cursor: pointer;
        }
</style>


Add one div above textbox to show list
  <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <br />
        <div ID="divwidth"></div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:AutoCompleteExtender ID="TextBox1_AutoCompleteExtender" runat="server"
            CompletionInterval="100" DelimiterCharacters="" Enabled="True"
            MinimumPrefixLength="1" ServiceMethod="GetCompletionList" ServicePath=""
            TargetControlID="TextBox1" UseContextKey="True"
            CompletionListItemCssClass="AutoExtenderList"
            CompletionListCssClass="AutoExtender"
            CompletionListHighlightedItemCssClass="AutoExtenderHighlight"
            CompletionListElementID="divwidth"></asp:AutoCompleteExtender>


Friday, November 2, 2012

'System.Drawing.Image' converted to 'System.Drawing.Icon in Windows Form Application

Here Is a simple solution when you get this error.You get this error when you are trying to change icon at runtime .Here is a simple Solution to that.

Dim img As Image = 'Whatever your image is...
Dim bm As Bitmap = img
Dim hIcon As IntPtr = bm.GetHicon
Dim TheIcon As Icon = Icon.FromHandle(hIcon)