vbnet Insert Record into DB

Private Function InsertUrl() As Boolean
	Dim s As New StringBuilder
	Dim ServerVariables As String = ""
	Dim IP As String = Request.ServerVariables("REMOTE_ADDR").ToString()
	Dim RowsAffected As Int32 = 0
	Dim conn As New SqlConnection(My.Settings.slickurls)
	Dim cmd As SqlCommand = New SqlCommand()

	For Each x In Request.ServerVariables
		s.Append(x & ":" & Request.ServerVariables(x).ToString & "|")

	ServerVariables = s.ToString

	With cmd
		.CommandText = "InsertUrl"
		.CommandType = CommandType.StoredProcedure
		.Parameters.AddWithValue("@UrlKey", UrlKey)
		.Parameters.AddWithValue("@Url", UrlIn)
		.Parameters.AddWithValue("@Title", UrlTitle)
		.Parameters.AddWithValue("@IP", IP)
		.Parameters.AddWithValue("@ServerVariables", ServerVariables)

		.Connection = conn
		RowsAffected = .ExecuteNonQuery()
	End With

	If RowsAffected > 0 Then
		Return True
		Return False
	End If
End Function
Inserts a record into a database - as used on slck.it

Updated: Saturday 9th October 2010, 04:44pm

There are 0 comments

Leave a comment of your own

Comments are currently closed.