dave1979bell
September 14th, 2005, 08:00 AM
I have went through the code step by step and it all apears to work fine, as it should however it does not add a record to th table.
Th stored procedure works fine when i execute it manualy and give it values, but this does not seem to excute it.
there are no errors when run and the connections to the db are fine there are no typos, i must be missing something at least i hope i am.
could someone please help this has puzzeled me for too long.
Thanks in advance
Dave
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim status As String = "NEW"
Dim urgency As String = CmbUrgency.Text
Dim description As String = TxtDescription.Text
Dim notes As String = TxtNotes.Text
Dim title As String = TxtTitle.Text
Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False;" + _
"Initial Catalog=TASK_LIST;Data Source=.\sqlexpress"
'//declare con varible and initalise it as a new sql conection with the
'//conection detail of the connectionstring detailed above
Dim con As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connectionString)
'//open a connection to the database
con.Open()
'Dim TEST = con.State
Try
Dim command As Data.SqlClient.SqlCommand = _
New Data.SqlClient.SqlCommand("Add_Task", con)
command.CommandType = Data.CommandType.StoredProcedure 'commandtype.StoredProcedure
command.Parameters.AddWithValue("@status", status)
command.Parameters.AddWithValue("@urgency", urgency)
command.Parameters.AddWithValue("@description", description)
command.Parameters.AddWithValue("@notes", notes)
command.Parameters.AddWithValue("@title", title)
'Dim test As Integer
command.ExecuteNonQuery()
'.ToString()
'Console.WriteLine("Rows inserted: " + _
'command.ExecuteNonQuery().ToString)
' Catch ex As Exception
'Console.WriteLine(ex.Message)
'Throw
Finally
con.Close()
End Try
End Sub
Th stored procedure works fine when i execute it manualy and give it values, but this does not seem to excute it.
there are no errors when run and the connections to the db are fine there are no typos, i must be missing something at least i hope i am.
could someone please help this has puzzeled me for too long.
Thanks in advance
Dave
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim status As String = "NEW"
Dim urgency As String = CmbUrgency.Text
Dim description As String = TxtDescription.Text
Dim notes As String = TxtNotes.Text
Dim title As String = TxtTitle.Text
Dim connectionString As String = _
"Integrated Security=SSPI;Persist Security Info=False;" + _
"Initial Catalog=TASK_LIST;Data Source=.\sqlexpress"
'//declare con varible and initalise it as a new sql conection with the
'//conection detail of the connectionstring detailed above
Dim con As Data.SqlClient.SqlConnection = New Data.SqlClient.SqlConnection(connectionString)
'//open a connection to the database
con.Open()
'Dim TEST = con.State
Try
Dim command As Data.SqlClient.SqlCommand = _
New Data.SqlClient.SqlCommand("Add_Task", con)
command.CommandType = Data.CommandType.StoredProcedure 'commandtype.StoredProcedure
command.Parameters.AddWithValue("@status", status)
command.Parameters.AddWithValue("@urgency", urgency)
command.Parameters.AddWithValue("@description", description)
command.Parameters.AddWithValue("@notes", notes)
command.Parameters.AddWithValue("@title", title)
'Dim test As Integer
command.ExecuteNonQuery()
'.ToString()
'Console.WriteLine("Rows inserted: " + _
'command.ExecuteNonQuery().ToString)
' Catch ex As Exception
'Console.WriteLine(ex.Message)
'Throw
Finally
con.Close()
End Try
End Sub