ok i figured how to do an insert...
went thru the usual web matrix insert query method, then added four text boxes, one for each field of the database that wasn't auto generated, and a button, in the event tag of the button added this bit of code..
Sub Button1_Click(sender As Object, e As EventArgs)
MyInsertMethod(TextBox1.Text,TextBox2.Text,TextBox 3.Text,TextBox4.Text)
end sub
followed by the auto generated insert function..
Function MyInsertMethod(ByVal title As String, ByVal notes As String, ByVal label As String, ByVal coverImageURL As String) As Integer
Dim connectionString As String = "server='(local)\netsdk'; trusted_connection=true; Database='CAM'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionStri ng)
Dim queryString As String = "INSERT INTO [Discs] ([Title], [ReleaseDate], [Notes], [Label], [CoverImageURL]) V"& _
"ALUES (@Title, getdate(), @Notes, @Label, @CoverImageURL)"
Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)
sqlCommand.Parameters.Add("@Title", System.Data.SqlDbType.VarChar).Value = title
sqlCommand.Parameters.Add("@Notes", System.Data.SqlDbType.Text).Value = notes
sqlCommand.Parameters.Add("@Label", System.Data.SqlDbType.VarChar).Value = label
sqlCommand.Parameters.Add("@CoverImageURL", System.Data.SqlDbType.VarChar).Value = coverImageURL
Dim rowsAffected As Integer = 0
sqlConnection.Open
Try
rowsAffected = sqlCommand.ExecuteNonQuery
Finally
sqlConnection.Close
End Try
Return rowsAffected
End Function
and hey presto it works.. so now any ideas how do i make delete work as such.. do i have to compare two fields from an input field??
|