Posts Tagged ‘asp.net’
How to return the Last Inserted ID in Datatable
Public Function AddToSubGroupTable(ByVal ParentID As Int32, ByVal masterID As Int32, ByVal FieldName As String, ByVal fieldAlias As String, ByVal Value As String, ByVal ValueText As String) As Long
Try
Dim dr As DataRow
With dtSubGroup.Rows
dr = dtSubGroup.NewRow
dr(“ParentID”) = ParentID
dr(“FieldName”) = FieldName
dr(“MasterFileID”) = masterID
dr(“Fieldalias”) = fieldAlias
dr(“Value”) = Value
dr(“ValueText”) = ValueText
.Add(dr)
End With
dtSubGroup.AcceptChanges()
Return dr(“PKID”).ToString
Catch ex As Exception
Throw New System.Exception(ex.Message, ex.InnerException)
End Try
End Function
Get Client IP Address
To get client IP address in ASP.NET
Function getIP() as String
Dim ip as string
ip = Request.UserHostAddress()
return ip
End Function
Connection TimeOut vs CommandTimeOut
Some programmers are confused the difference between of the ConnectionTimeout and CommandTimeout, so here is the distinction between the two.
ConnectionTimeout is the one specified in your connection string and it is the time it takes for a connection.Open() invocation to wait until it gets a connection reference from the connection pool. (Default value is 15 seconds)
CommandTimeout is the maximum time for a specific sql command to execute. (Default value is 30 seconds)