String Format for Double [C#]

The following examples show how to format float numbers to string in C#. You can use static method String.Format or instance methods double.ToString and float.ToString.

Digits after decimal point

This example formats double to string with fixed number of decimal places. For two decimal places use pattern „0.00“. If a float number has less decimal places, the rest digits on the right will be zeroes. If it has more decimal places, the number will be rounded.

 

// just two decimal places
String.Format("{0:0.00}", 123.4567);      // "123.46"
String.Format("{0:0.00}", 123.4);         // "123.40"
String.Format("{0:0.00}", 123.0);         // "123.00"

Next example formats double to string with floating number of decimal places. E.g. for maximal two decimal places use pattern „0.##“.

// max. two decimal places
String.Format("{0:0.##}", 123.4567);      // "123.46"
String.Format("{0:0.##}", 123.4);         // "123.4"
String.Format("{0:0.##}", 123.0);         // "123"

Digits before decimal point

If you want a float number to have any minimal number of digits before decimal point use N-times zero before decimal point. E.g. pattern „00.0“ formats a float number to string with at least two digits before decimal point and one digit after that.

// at least two digits before decimal point
String.Format("{0:00.0}", 123.4567);      // "123.5"
String.Format("{0:00.0}", 23.4567);       // "23.5"
String.Format("{0:00.0}", 3.4567);        // "03.5"
String.Format("{0:00.0}", -3.4567);       // "-03.5"

 

Thousands separator

To format double to string with use of thousands separator use zero and comma separator before an usual float formatting pattern, e.g. pattern „0,0.0“ formats the number to use thousands separators and to have one decimal place.

 

String.Format("{0:0,0.0}", 12345.67);     // "12,345.7"
String.Format("{0:0,0}", 12345.67);       // "12,346"

 

Zero

Float numbers between zero and one can be formatted in two ways, with or without leading zero before decimal point. To format number without a leading zero use # before point. For example „#.0“ formats number to have one decimal place and zero to N digits before decimal point (e.g. „.5“ or „123.5“).

Following code shows how can be formatted a zero (of double type).

 

String.Format("{0:0.0}", 0.0);            // "0.0"
String.Format("{0:0.#}", 0.0);            // "0"
String.Format("{0:#.0}", 0.0);            // ".0"
String.Format("{0:#.#}", 0.0);            // ""

 

Align numbers with spaces

To align float number to the right use comma „,“ option before the colon. Type comma followed by a number of spaces, e.g. „0,10:0.0“ (this can be used only in String.Format method, not in double.ToString method). To align numbers to the left use negative number of spaces.

 

String.Format("{0,10:0.0}", 123.4567);    // "     123.5"
String.Format("{0,-10:0.0}", 123.4567);   // "123.5     "
String.Format("{0,10:0.0}", -123.4567);   // "    -123.5"
String.Format("{0,-10:0.0}", -123.4567);  // "-123.5    "

Custom formatting for negative numbers and zero

If you need to use custom format for negative float numbers or zero, use semicolon separator;“ to split pattern to three sections. The first section formats positive numbers, the second section formats negative numbers and the third section formats zero. If you omit the last section, zero will be formatted using the first section.

 

String.Format("{0:0.00;minus 0.00;zero}", 123.4567);   // "123.46"
String.Format("{0:0.00;minus 0.00;zero}", -123.4567);  // "minus 123.46"
String.Format("{0:0.00;minus 0.00;zero}", 0.0);        // "zero"

Some funny examples

As you could notice in the previous example, you can put any text into formatting pattern, e.g. before an usual pattern „my text 0.0“. You can even put any text between the zeroes, e.g. „0aaa.bbb0“.

String.Format("{0:my number is 0.0}", 12.3);   // "my number is 12.3"
String.Format("{0:0aaa.bbb0}", 12.3);          // "12aaa.bbb3"

 

Khắc phục lỗi Visual Studio 2008 Debug bằng firefox chạy chậm trên Win7

Lúc trước tui chạy win 7 thấy Debug Visual Studio 2008 tại firefox rất nhanh sau khi quyết định lên đời win7 thì thì debug trên firefox rất chậm làm điên đách chiệu nổi sau hồi tìm hiểu thì đã biết các phục

ta làm các bước như sau:

    * vào address gõ  "about:config"
    * Tại Filter gõ  "v6"
    * tắt chế độ ipv6.

Như hình hình minh họa

 

 

thể là xong không sợ chậm nữa

SQL Data Provider VB.NET Class

Imports System
Imports System.IO
Imports System.Text
Imports System.Data
Imports System.Data.SqlClient

Namespace SqlDataProvider

    ''' <summary>
    ''' This class provides a fast and universal method for accessing SQL Server database.This class cannot be inherited.
    ''' </summary>
    Public NotInheritable Class SqlDatabase

#Region " Local Property Declarations "

        Dim _connectionString As String

#End Region

#Region " Constructor "

        ''' <summary>
        ''' Initializes a new instance of the ADO.SqlDatabase class.
        ''' </summary>
        ''' <param name="connectionString">The connection used to open the SQL Server database.</param>
        Public Sub New(ByVal connectionString As String)
            _connectionString = connectionString
        End Sub

#End Region

#Region " Public Properties "

        ''' <summary>
        ''' Gets or sets the string used to open a SQL Server database.
        ''' </summary>
        ''' <returns>The connection string that includes the source database name, and other parameters needed to establish the initial connection.</returns>
        Public Property ConnectionString() As String
            Get
                Return _connectionString
            End Get
            Set(ByVal value As String)
                _connectionString = value
            End Set
        End Property

#End Region

#Region " Private Methods "

        Private Sub AssignParameters(ByVal cmd As SqlCommand, ByVal cmdParameters() As SqlParameter)
            If (cmdParameters Is Nothing) Then Exit Sub
            For Each p As SqlParameter In cmdParameters
                cmd.Parameters.Add(p)
            Next
        End Sub

        Private Sub AssignParameters(ByVal cmd As SqlCommand, ByVal parameterValues() As Object)
            If Not (cmd.Parameters.Count - 1 = parameterValues.Length) Then Throw New ApplicationException("Stored procedure's parameters and parameter values does not match.")
            Dim i As Integer
            For Each param As SqlParameter In cmd.Parameters
                If Not (param.Direction = ParameterDirection.Output) AndAlso Not (param.Direction = ParameterDirection.ReturnValue) Then
                    param.Value = parameterValues(i)
                    i += 1
                End If
            Next
        End Sub

#End Region

#Region " ExecuteNonQuery "

        ''' <summary>
        ''' Executes a Transact-SQL statement against the connection and returns the number of rows affected.
        ''' </summary>
        ''' <param name="cmd">The Transact-SQL statement or stored procedure to execute at the data source.</param>
        ''' <param name="cmdType">A value indicating how the System.Data.SqlClient.SqlCommand.CommandText property is to be interpreted.</param>
        ''' <param name="parameters">The parameters of the Transact-SQL statement or stored procedure.</param>
        ''' <returns>The number of rows affected.</returns>
        Public Function ExecuteNonQuery(ByVal cmd As String, ByVal cmdType As CommandType, Optional ByVal parameters() As SqlParameter = Nothing) As Integer
            Dim connection As SqlConnection = Nothing
            Dim transaction As SqlTransaction = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As Integer = -1
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(cmd, connection)
                command.CommandType = cmdType
                Me.AssignParameters(command, parameters)
                connection.Open()
                transaction = connection.BeginTransaction()
                command.Transaction = transaction
                res = command.ExecuteNonQuery()
                transaction.Commit()
            Catch ex As Exception
                If Not (transaction Is Nothing) Then
                    transaction.Rollback()
                End If
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()
                If Not (command Is Nothing) Then command.Dispose()
                If Not (transaction Is Nothing) Then transaction.Dispose()
            End Try
            Return res
        End Function

        ''' <summary>
        ''' Executes a Transact-SQL statement against the connection and returns the number of rows affected.
        ''' </summary>
        ''' <param name="spname">The stored procedure to execute at the data source.</param>
        ''' <param name="returnValue">The returned value from stored procedure.</param>
        ''' <param name="parameterValues">The parameter values of the stored procedure.</param>
        ''' <returns>The number of rows affected.</returns>
        Public Function ExecuteNonQuery(ByVal spname As String, ByRef returnValue As Integer, ByVal ParamArray parameterValues() As Object) As Integer
            Dim connection As SqlConnection = Nothing
            Dim transaction As SqlTransaction = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As Integer = -1
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(spname, connection)
                command.CommandType = CommandType.StoredProcedure
                connection.Open()
                SqlCommandBuilder.DeriveParameters(command)
                Me.AssignParameters(command, parameterValues)
                transaction = connection.BeginTransaction()
                command.Transaction = transaction
                res = command.ExecuteNonQuery()
                returnValue = command.Parameters(0).Value
                transaction.Commit()
            Catch ex As Exception
                If Not (transaction Is Nothing) Then
                    transaction.Rollback()
                End If
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()
                If Not (command Is Nothing) Then command.Dispose()
                If Not (transaction Is Nothing) Then transaction.Dispose()
            End Try
            Return res
        End Function

#End Region

#Region " ExecuteScalar "

        ''' <summary>
        ''' Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
        ''' </summary>
        ''' <param name="cmd">The Transact-SQL statement or stored procedure to execute at the data source.</param>
        ''' <param name="cmdType">A value indicating how the System.Data.SqlClient.SqlCommand.CommandText property is to be interpreted.</param>
        ''' <param name="parameters">The parameters of the Transact-SQL statement or stored procedure.</param>
        ''' <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
        Public Function ExecuteScalar(ByVal cmd As String, ByVal cmdType As CommandType, Optional ByVal parameters() As SqlParameter = Nothing) As Object
            Dim connection As SqlConnection = Nothing
            Dim transaction As SqlTransaction = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As Object = Nothing
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(cmd, connection)
                command.CommandType = cmdType
                Me.AssignParameters(command, parameters)
                connection.Open()
                transaction = connection.BeginTransaction()
                command.Transaction = transaction
                res = command.ExecuteScalar()
                transaction.Commit()
            Catch ex As Exception
                If Not (transaction Is Nothing) Then
                    transaction.Rollback()
                End If
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()
                If Not (command Is Nothing) Then command.Dispose()
                If Not (transaction Is Nothing) Then transaction.Dispose()
            End Try
            Return res
        End Function

        ''' <summary>
        ''' Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
        ''' </summary>
        ''' <param name="spname">The stored procedure to execute at the data source.</param>
        ''' <param name="returnValue">The returned value from stored procedure.</param>
        ''' <param name="parameterValues">The parameter values of the stored procedure.</param>
        ''' <returns>The first column of the first row in the result set, or a null reference if the result set is empty.</returns>
        Public Function ExecuteScalar(ByVal spname As String, ByRef returnValue As Integer, ByVal ParamArray parameterValues() As Object) As Object
            Dim connection As SqlConnection = Nothing
            Dim transaction As SqlTransaction = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As Object = Nothing
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(spname, connection)
                command.CommandType = CommandType.StoredProcedure
                connection.Open()
                SqlCommandBuilder.DeriveParameters(command)
                Me.AssignParameters(command, parameterValues)
                transaction = connection.BeginTransaction()
                command.Transaction = transaction
                res = command.ExecuteScalar()
                returnValue = command.Parameters(0).Value
                transaction.Commit()
            Catch ex As Exception
                If Not (transaction Is Nothing) Then
                    transaction.Rollback()
                End If
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()
                If Not (command Is Nothing) Then command.Dispose()
                If Not (transaction Is Nothing) Then transaction.Dispose()
            End Try
            Return res
        End Function

#End Region

#Region " ExecuteReader "

        ''' <summary>
        ''' Sends the System.Data.SqlClient.SqlCommand.CommandText to the System.Data.SqlClient.SqlCommand.Connection, and builds a System.Data.SqlClient.SqlDataReader using one of the System.Data.CommandBehavior values.
        ''' </summary>
        ''' <param name="cmd">The Transact-SQL statement or stored procedure to execute at the data source.</param>
        ''' <param name="cmdType">A value indicating how the System.Data.SqlClient.SqlCommand.CommandText property is to be interpreted.</param>
        ''' <param name="parameters">The parameters of the Transact-SQL statement or stored procedure.</param>
        ''' <returns>A System.Data.SqlClient.SqlDataReader object.</returns>
        Public Function ExecuteReader(ByVal cmd As String, ByVal cmdType As CommandType, Optional ByVal parameters() As SqlParameter = Nothing) As IDataReader
            Dim connection As SqlConnection = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As SqlDataReader = Nothing
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(cmd, connection)
                command.CommandType = cmdType
                Me.AssignParameters(command, parameters)
                connection.Open()
                res = command.ExecuteReader(CommandBehavior.CloseConnection)
            Catch ex As Exception
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            End Try
            Return CType(res, IDataReader)
        End Function

        ''' <summary>
        ''' Sends the System.Data.SqlClient.SqlCommand.CommandText to the System.Data.SqlClient.SqlCommand.Connection, and builds a System.Data.SqlClient.SqlDataReader using one of the System.Data.CommandBehavior values.
        ''' </summary>
        ''' <param name="spname">The stored procedure to execute at the data source.</param>
        ''' <param name="returnValue">The returned value from stored procedure.</param>
        ''' <param name="parameterValues">The parameter values of the stored procedure.</param>
        ''' <returns>A System.Data.SqlClient.SqlDataReader object.</returns>
        Public Function ExecuteReader(ByVal spname As String, ByRef returnValue As Integer, ByVal ParamArray parameterValues() As Object) As IDataReader
            Dim connection As SqlConnection = Nothing
            Dim command As SqlCommand = Nothing
            Dim res As SqlDataReader = Nothing
            Try
                connection = New SqlConnection(ConnectionString)
                command = New SqlCommand(spname, connection)
                command.CommandType = CommandType.StoredProcedure
                connection.Open()
                SqlCommandBuilder.DeriveParameters(command)
                Me.AssignParameters(command, parameterValues)
                res = command.ExecuteReader(CommandBehavior.CloseConnection)
                returnValue = command.Parameters(0).Value
            Catch ex As Exception
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            End Try
            Return CType(res, IDataReader)
        End Function

#End Region

#Region " FillDataset "

        ''' <summary>
        ''' Adds or refreshes rows in the System.Data.DataSet to match those in the data source using the System.Data.DataSet name, and creates a System.Data.DataTable named "Table."
        ''' </summary>
        ''' <param name="cmd">The Transact-SQL statement or stored procedure to execute at the data source.</param>
        ''' <param name="cmdType">A value indicating how the System.Data.SqlClient.SqlCommand.CommandText property is to be interpreted.</param>
        ''' <param name="parameters">The parameters of the Transact-SQL statement or stored procedure.</param>
        ''' <returns>A System.Data.Dataset object.</returns>
        Public Function FillDataset(ByVal cmd As String, ByVal cmdType As CommandType, Optional ByVal parameters() As SqlParameter = Nothing) As DataSet
            Dim connection As SqlConnection = Nothing
            Dim command As SqlCommand = Nothing
            Dim sqlda As SqlDataAdapter = Nothing
            Dim res As New DataSet
            Try
                connection = New SqlConnection(_connectionString)
                command = New SqlCommand(cmd, connection)
                command.CommandType = cmdType
                AssignParameters(command, parameters)
                sqlda = New SqlDataAdapter(command)
                sqlda.Fill(res)
            Catch ex As Exception
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) Then connection.Dispose()
                If Not (command Is Nothing) Then command.Dispose()
                If Not (sqlda Is Nothing) Then sqlda.Dispose()
            End Try
            Return res
        End Function

#End Region

#Region " ExecuteDataset "

        ''' <summary>
        ''' Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the System.Data.DataSet with the specified System.Data.DataTable name.
        ''' </summary>
        ''' <param name="insertCmd">A command used to insert new records into the data source.</param>
        ''' <param name="updateCmd">A command used to update records in the data source.</param>
        ''' <param name="deleteCmd">A command for deleting records from the data set.</param>
        ''' <param name="ds">The System.Data.DataSet to use to update the data source. </param>
        ''' <param name="srcTable">The name of the source table to use for table mapping.</param>
        ''' <returns>The number of rows successfully updated from the System.Data.DataSet.</returns>
        Public Function ExecuteDataset(ByVal insertCmd As SqlCommand, ByVal updateCmd As SqlCommand, ByVal deleteCmd As SqlCommand, ByVal ds As DataSet, ByVal srcTable As String) As Integer
            Dim connection As SqlConnection = Nothing
            Dim sqlda As SqlDataAdapter = Nothing
            Dim res As Integer = 0
            Try
                connection = New SqlConnection(_connectionString)
                sqlda = New SqlDataAdapter
                If Not (insertCmd Is Nothing) Then insertCmd.Connection = connection : sqlda.InsertCommand = insertCmd
                If Not (updateCmd Is Nothing) Then updateCmd.Connection = connection : sqlda.UpdateCommand = updateCmd
                If Not (deleteCmd Is Nothing) Then deleteCmd.Connection = connection : sqlda.DeleteCommand = deleteCmd
                res = sqlda.Update(ds, srcTable)
            Catch ex As Exception
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If Not (connection Is Nothing) Then connection.Dispose()
                If Not (insertCmd Is Nothing) Then insertCmd.Dispose()
                If Not (updateCmd Is Nothing) Then updateCmd.Dispose()
                If Not (deleteCmd Is Nothing) Then deleteCmd.Dispose()
                If Not (sqlda Is Nothing) Then sqlda.Dispose()
            End Try
            Return res
        End Function

#End Region

#Region " ExecuteScript "

        ''' <summary>
        ''' Executes a SQL query file against the connection.
        ''' </summary>
        ''' <param name="filename">SQL query file name.</param>
        ''' <param name="parameters">The parameters of the SQL query file.</param>
        Public Sub ExecuteScript(ByVal filename As String, Optional ByVal parameters() As SqlParameter = Nothing)
            Dim fStream As FileStream = Nothing
            Dim sReader As StreamReader = Nothing
            Dim connection As SqlConnection = Nothing
            Dim command As SqlCommand = Nothing
            Try
                fStream = New FileStream(filename, FileMode.Open, FileAccess.Read)
                sReader = New StreamReader(fStream)
                connection = New SqlConnection(ConnectionString)
                command = connection.CreateCommand()
                connection.Open()
                While (Not sReader.EndOfStream)
                    Dim sb As New StringBuilder
                    While (Not sReader.EndOfStream)
                        Dim s As String = sReader.ReadLine
                        If (Not String.IsNullOrEmpty(s)) AndAlso (s.ToUpper.Trim = "GO") Then
                            Exit While
                        End If
                        sb.AppendLine(s)
                    End While
                    command.CommandText = sb.ToString
                    command.CommandType = CommandType.Text
                    AssignParameters(command, parameters)
                    command.ExecuteNonQuery()
                End While
            Catch ex As Exception
                Throw New SqlDatabaseException(ex.Message, ex.InnerException)
            Finally
                If (Not IsNothing(connection)) AndAlso (connection.State = ConnectionState.Open) Then connection.Close()
                If (Not IsNothing(command)) Then command.Dispose()
                If (Not IsNothing(sReader)) Then sReader.Close()
                If (Not IsNothing(fStream)) Then fStream.Close()
            End Try
        End Sub

#End Region

    End Class

End Namespace

SqlDatabaseException

Namespace SqlDataProvider

    ''' <summary>
    ''' Represents errors that occur during application execution.
    ''' </summary>
    Public Class SqlDatabaseException
        Inherits Exception

#Region " Constructor "

        ''' <summary>
        ''' Initializes a new instance of the ADO.SqlDatabaseException class.
        ''' </summary>
        Public Sub New()
        End Sub

        ''' <summary>
        ''' Initializes a new instance of the ADO.SqlDatabaseException class with a specified error message.
        ''' </summary>
        ''' <param name="message">The message that describes the error.</param>
        Public Sub New(ByVal message As String)
            MyBase.New(message)
        End Sub

        ''' <summary>
        ''' Initializes a new instance of the ADO.SqlDatabaseException class with a specified error message and a reference to the inner exception that is the cause of this exception.
        ''' </summary>
        ''' <param name="message">The error message that explains the reason for the exception.</param>
        ''' <param name="innerException">The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.</param>
        Public Sub New(ByVal message As String, ByVal innerException As Exception)
            MyBase.New(message, innerException)
        End Sub

#End Region

    End Class

End Namespace

Cách sử dụng

SQLDataProvider Class Documentation
This class provides a fast and universal method for accessing SQL Server database.
Create Instance
At first you create an instance of SqlDatabase class.

 

Dim sqldb As New SqlDatabase("Data Source=(local); Initial Catalog= ; UId = ; Pwd = ;")

For more information about connection strings, visit ConnectionStrings.com.

ExecuteNonQuery Method


Executes a Transact-SQL statement against the connection and returns the number of rows affected.

 

 

Dim params(0 To 1) As SqlParameter
params(0) = New SqlParameter("@Firstname", SqlDbType.NVarChar, 120)
params(0).Value = "Stefan"
params(1) = New SqlParameter("@Lastname", SqlDbType.NVarChar, 120)
params(1).Value = "Cameron"
sqldb.ExecuteNonQuery("Insert Into dbo.Users(Firstname, LastName) Values(@FirstName, @LastName)", CommandType.Text, params)

If you are using stored procedure,you can execute that without declaring parameters such as following code:

sqldb.ExecuteNonQuery("dbo.CreateUser", Nothing, "Stefan", "Cameron")

ExecuteScalar Method

Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.

Dim count As Integer = sqldb.ExecuteScalar("Select Count(*) From dbo.Users", CommandType.Text)
MsgBox("Number of row(s): " & count)


ExecuteReader Method
Sends the CommandText to the Connection and builds a SqlDataReader.

Dim FirstName As String = String.Empty
Dim LastName As String = String.Empty

Dim params(0) As SqlParameter
params(0) = New SqlParameter("@Id", SqlDbType.Int)
params(0).Value = 1

Dim dr As IDataReader = sqldb.ExecuteReader("Select * From dbo.Users Where (Id = @Id)", CommandType.Text, params)
While dr.Read()
    FirstName = dr("Firstname")
    LastName = dr("Lastname")
End While
dr.Close()

MsgBox(FirstName & " " & LastName, MsgBoxStyle.Information)

There is a sample for using stored procedure:

Create Procedure [dbo].[GetUserInfo]
    (
        @Id int
    )
As
Begin
    Select * From dbo.Users Where (Id = @Id)
End
Dim FirstName As String = String.Empty
Dim LastName As String = String.Empty

Dim dr As IDataReader = sqldb.ExecuteReader("dbo.GetUserInfo", Nothing, 1)
While dr.Read()
    FirstName = dr("Firstname")
    LastName = dr("Lastname")
End While
dr.Close()

MsgBox(FirstName & " " & LastName, MsgBoxStyle.Information)

Using Return Value Parameter
If you are using stored procedure,you can get the value of 'return value parameter'.

Create Procedure dbo.UserExists
    (
        @Firstname nvarchar(120),
        @Lastname nvarchar(120)
    )
As
Begin
    If Exists(Select * From dbo.Users Where (Firstname = @Firstname) And (Lastname = @Lastname))
        Return 1
End
Dim retval As Integer
sqldb.ExecuteNonQuery("dbo.UserExists", retval, "Stefan", "Cameron")
MsgBox("User Exists: " & IIf(retval = 1, "Yes", "No"))

FillDataset Method
Adds or refreshes rows in the System.Data.DataSet to match those in the data source using the System.Data.DataSet name, and creates a System.Data.DataTable named "Table."
Binding a DataGridView with FillDataset method.

DataGridView1.DataSource = sqldb.FillDataset("Select * From dbo.Users", CommandType.Text).Tables(0)

ExecuteDataset Method

Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the System.Data.DataSet with the specified System.Data.DataTable name.

' Getting the System.Data.DataSet.
Dim ds As DataSet = CType(DataGridView1.DataSource, DataTable).DataSet

' Declaring insert command object
Dim inscmd As New SqlCommand("Insert Into dbo.Users(Firstname, Lastname) Values(@Firstname, @Lastname)")
With inscmd
    .CommandType = CommandType.Text
    .Parameters.Add(New SqlParameter("@Firstname", SqlDbType.NVarChar, 120)).SourceColumn = "Firstname"
    .Parameters.Add(New SqlParameter("@Lastname", SqlDbType.NVarChar, 120)).SourceColumn = "Lastname"
End With

' Declaring update command object
Dim updcmd As New SqlCommand("Update dbo.Users Set Firstname = @Firstname, Lastname = @Lastname Where (Id = @Id)")
With updcmd
    .CommandType = CommandType.Text
    .Parameters.Add(New SqlParameter("@Id", SqlDbType.Int)).SourceColumn = "Id"
    .Parameters.Add(New SqlParameter("@Firstname", SqlDbType.NVarChar, 120)).SourceColumn = "Firstname"
    .Parameters.Add(New SqlParameter("@Lastname", SqlDbType.NVarChar, 120)).SourceColumn = "Lastname"
End With

' Declaring delete command object
Dim delcmd As New SqlCommand("Delete From dbo.Users Where (Id = @Id)")
With delcmd
    .CommandType = CommandType.Text
    .Parameters.Add(New SqlParameter("@Id", SqlDbType.Int)).SourceColumn = "Id"
End With

' Updating data source
sqldb.ExecuteDataset(inscmd, updcmd, delcmd, ds, ds.Tables(0).TableName)

 

Microsoft SQL Server 2008 R2 Enterprise Edition x86 and x64

Microsoft SQL Server 2008 R2 Enterprise Edition x86 and x64|Size 3.01 GB
SQL Server 2008 R2 delivers several breakthrough capabilities that will enable your organization to scale database operations with confidence, improve IT and developer efficiency, and enable highly scalable and well managed Business Intelligence on a self-service basis for your users.

RELEASE iNFORMATiON
CRACKER: TEAM Z.W.T
SUPPLiER: TEAM Z.W.T
PACKER: TEAM Z.W.T
RELEASE DATE: 04/29/2010
FORMAT: iSO
SiZE: 1 DVD
PLATFORM: WinALL
SOFTWARE TYPE: UTIL
LANGUAGE: ENGLiSH

 

http://hotfile.com/dl/41323733/0f01557/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part01.rar.html
http://hotfile.com/dl/41323890/bf112f0/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part02.rar.html
http://hotfile.com/dl/41324070/68a9f2e/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part03.rar.html
http://hotfile.com/dl/41324236/3958620/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part04.rar.html
http://hotfile.com/dl/41324777/52bdabc/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part05.rar.html
http://hotfile.com/dl/41330898/248b9ef/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part06.rar.html
http://hotfile.com/dl/41331228/a0e270f/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part07.rar.html
http://hotfile.com/dl/41331553/9d20e76/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part08.rar.html
http://hotfile.com/dl/41331866/e7fa364/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part09.rar.html
http://hotfile.com/dl/41332339/8045c6c/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part10.rar.html
http://hotfile.com/dl/41332712/b84506d/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part11.rar.html
http://hotfile.com/dl/41333036/ce026f6/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part12.rar.html
http://hotfile.com/dl/41333425/4e0e47b/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part13.rar.html
http://hotfile.com/dl/41333672/4c58c83/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part14.rar.html
http://hotfile.com/dl/41333976/be2da61/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part15.rar.html
http://hotfile.com/dl/41334076/4cac270/IMRCSOFO.TQS.LESVRRE2.00.82RE.TNRERPSI.EDETIOI.N8X.6NA.D6X-4WZITOS.part16.rar.html

Default Password: tactools.org

240 plugin hữu ích của JQuery

Với JQuery mọi thứ đều tuyệt vời và đơn giản tới bất ngờ. Bài viết này lấy từ site http://www.kollermedia.at sẽ giới thiệu cho bạn 240 plugin hữu ích cho JQuery để bạn có thể dễ dàng áp dụng vào công việc.

Form Validation

File upload

Form – Select Box stuff

Form Basics, Input Fields, Checkboxes etc.

Time, Date and Color Picker

Rating Plugins

Search Plugins

Inline Edit & Editors

Audio, Video, Flash, SVG, etc

Photos/Images/Galleries

Google Map

Games

Tables, Grids etc.

Charts, Presentation etc.

Border, Corners, Background

Text and Links

Tooltips

Menus, Navigations

Accordions, Slide and Toggle stuff

Drag and Drop

XML XSL JSON Feeds

Browserstuff

Alert, Prompt, Confirm Windows

CSS

DOM, Ajax and other jQuery plugins

(Nguồn: http://www.kollermedia.at)