J
Jorge Cavalheiro
Hello
I've just read in Visual Studio Magazine Nov 2003 that
using parameters in a sqlcommand is 37% faster than 'Exec
procedure_name param1,param2,etc'. So i was trying to use
it.
<code>
Me.SqlCommand2.Connection = Me.SqlConnection1
Me.SqlCommand2.CommandType = CommandType.StoredProcedure
Me.SqlCommand2.CommandText = "imprime_linha_mapa"
With Me.SqlCommand2.Parameters
.Add("@worker", SqlDbType.Char).Value = "-1"
.Add("@posto", SqlDbType.Decimal).Value = 0
.Add("@obra", SqlDbType.Char).Value = ""
.Add("@inicio", SqlDbType.Char).Value = ""
.Add("@fim", SqlDbType.Char).Value = ""
.Add("@deltah", SqlDbType.Char).Value = ""
.Add("@delta", SqlDbType.Decimal).Value = 0
.Add("@mov", SqlDbType.Decimal).Value = mov
End With
'Me.SqlCommand2.CommandText = "exec imprime_linha_mapa '-
1',0,'','','','',0," & mov.ToString
Try
Me.SqlCommand2.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Me.SqlConnection1.Close()
Exit Sub
End Try
</code>
I get the following exception : Procedure or function
imprime_linha_mapa has too many arguments specified.
But that doesn't make any sense since the stored
procedure 'imprime_linha_mapa' has the following
declaration:
<code>
ALTER PROCEDURE imprime_linha_mapa
@worker char(255),
@posto numeric(3,0),
@obra char(8),
@inicio char(20),
@fim char(20),
@deltah char(8),
@delta numeric(6,2),
@mov numeric(9,0)
AS
</code>
What am i doing wrong? Any suggestion would be most
welcome, thanks!
Kind Regards
Jorge Cavalheiro
I've just read in Visual Studio Magazine Nov 2003 that
using parameters in a sqlcommand is 37% faster than 'Exec
procedure_name param1,param2,etc'. So i was trying to use
it.
<code>
Me.SqlCommand2.Connection = Me.SqlConnection1
Me.SqlCommand2.CommandType = CommandType.StoredProcedure
Me.SqlCommand2.CommandText = "imprime_linha_mapa"
With Me.SqlCommand2.Parameters
.Add("@worker", SqlDbType.Char).Value = "-1"
.Add("@posto", SqlDbType.Decimal).Value = 0
.Add("@obra", SqlDbType.Char).Value = ""
.Add("@inicio", SqlDbType.Char).Value = ""
.Add("@fim", SqlDbType.Char).Value = ""
.Add("@deltah", SqlDbType.Char).Value = ""
.Add("@delta", SqlDbType.Decimal).Value = 0
.Add("@mov", SqlDbType.Decimal).Value = mov
End With
'Me.SqlCommand2.CommandText = "exec imprime_linha_mapa '-
1',0,'','','','',0," & mov.ToString
Try
Me.SqlCommand2.ExecuteNonQuery()
Catch ex As Exception
MessageBox.Show(ex.Message)
Me.SqlConnection1.Close()
Exit Sub
End Try
</code>
I get the following exception : Procedure or function
imprime_linha_mapa has too many arguments specified.
But that doesn't make any sense since the stored
procedure 'imprime_linha_mapa' has the following
declaration:
<code>
ALTER PROCEDURE imprime_linha_mapa
@worker char(255),
@posto numeric(3,0),
@obra char(8),
@inicio char(20),
@fim char(20),
@deltah char(8),
@delta numeric(6,2),
@mov numeric(9,0)
AS
</code>
What am i doing wrong? Any suggestion would be most
welcome, thanks!
Kind Regards
Jorge Cavalheiro