Hi,
I am having problems inserting data into a table using a stored procedure. When I click the button to insert the data nothing happens at all. I added a server.transfer after the insert to see if it was falling over before the end of the query/insert.
My code behind the button to insert the data is as follows...
Imports System.Data
Imports System.Data.SqlClient
Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim ConnString As New SqlConnection
ConnString.ConnectionString = "Data Source=.\SQLEXPRESS2008;Initial Catalog=mkb;Integrated Security=True"
ConnString.Open()
Dim SQLCmd As New SqlCommand
SQLCmd.CommandText = "usp_insertError" 'name of SP
SQLCmd.CommandType = CommandType.StoredProcedure
SQLCmd.Connection = ConnString 'Active SQL Connection to DB
SQLCmd.Parameters.AddWithValue("errorTitle", TxtBoxTitle.Text)
'SQLCmd.Parameters.AddWithValue("errorProg", DDListProg.SelectedValue)
'SQLCmd.Parameters.AddWithValue("errorCat", DDListCat.SelectedValue)
'SQLCmd.Parameters.AddWithValue("errorSubCat", DDListSubCat.SelectedValue)
SQLCmd.Parameters.AddWithValue("errorDesc", TxtBoxDesc.Text)
SQLCmd.Parameters.AddWithValue("errorCreated", Date.Now)
'SQLCmd.Parameters.AddWithValue("errorAuthor", errorTitle.text)
'SQLCmd.Parameters.AddWithValue("errorSeverity", RadioListSeverity.SelectedValue)
SQLCmd.ExecuteNonQuery()
ConnString.Close()
I have commented a couple of items out as I am working on them at the moment, instead I have set their values in the Stored Procedure so it should work anyway.
Stored Proc is as follows;
ALTER PROCEDURE [dbo].[usp_insertError]
@errorTitle varchar(150),
@errorProg int,
@errorCat int,
@errorSubCat int,
@errorDesc text,
@errorCreated date,
@errorAuthor int,
@errorSeverity int
AS
SET @errorProg='1'
SET @errorCat='3'
SET @errorSubCat='2'
SET @errorSeverity='2'
INSERT INTO errors(errorTitle, errorProg, errorCat, errorSubCat, errorDesc,
errorCreated, errorSeverity)
VALUES (@errorTitle, @errorProg, @errorCat, @errorSubCat, @errorDesc,
GETDATE(), @errorSeverity)
thanks in advance