Click to See Complete Forum and Search --> : Please Help!!!!!!!!


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

sebastiansony
September 14th, 2005, 08:33 AM
try adding parameter by specifying data type


dim param1 as SqlParameter=command.parameters.add("@param1",SqlDBType.int)
param1.direction=parameterDirection.input
param1.value=value1

dave1979bell
September 14th, 2005, 09:16 AM
Sorry i am not really sure where to use this in my code, could you please elabirate?

Thanks,

Dave

dave1979bell
September 14th, 2005, 09:55 AM
ok i put it in like this still no difrence

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


Dim status As Data.SqlClient.SqlParameter = command.Parameters.AddWithValue("@status", Data.SqlDbType.Char)
Dim urgency As Data.SqlClient.SqlParameter = command.Parameters.AddWithValue("@urgency", Data.SqlDbType.Char)
Dim description As Data.SqlClient.SqlParameter = command.Parameters.AddWithValue("@description", Data.SqlDbType.Char)
Dim notes As Data.SqlClient.SqlParameter = command.Parameters.AddWithValue("@notes", Data.SqlDbType.Char)
Dim title As Data.SqlClient.SqlParameter = command.Parameters.AddWithValue("@title", Data.SqlDbType.Char)

status.Direction = Data.ParameterDirection.Input
urgency.Direction = Data.ParameterDirection.Input
description.Direction = Data.ParameterDirection.Input
notes.Direction = Data.ParameterDirection.Input
title.Direction = Data.ParameterDirection.Input

status.Value = "NEW"

urgency.Value = CmbUrgency.Text
description.Value = TxtDescription.Text
notes.Value = TxtNotes.Text
title.Value = TxtTitle.Text

'param1.value = value1
'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

Any Ideas

dave1979bell
September 14th, 2005, 10:58 AM
Please can someone help here i really am truly stuck.

Best Regards,

Dave

dave1979bell
September 15th, 2005, 03:48 AM
does noone know what I am doing wrong?

dave1979bell
September 15th, 2005, 11:03 AM
does anyone even know where else i migh find out?