tehon3299
Centurion
I am using the code below (VB) to insert things into an SQL database. I want to use this code on a C# page. How can I do this?
Visual Basic:
Dim MyCommand As New SqlCommand
Dim MyConnection As New SqlConnection
Dim MySQLDataAdapter as New SqlDataAdapter
Dim SessionCmd As String
SessionCmd = "INSERT INTO tmPicIndex (UserID, PicName, PicDesc) VALUES ('" & user & "', '" & savename.Value & "', 0)"
MyConnection = New SqlConnection("server=(local);database=PictureShare;Trusted_Connection=yes")
MyCommand = New SqlCommand(SessionCmd, MyConnection)
MyCommand.Connection.Open()
Try
MyCommand.ExecuteNonQuery()
Catch Exp As SQLException
If Exp.Number = 2627
Else
End If
End Try
MyCommand.Connection.Close()