A
ADF
I have wrote this code:
-----------------------------------------------------------------------------
Dim cnsql As New SqlClient.SqlConnection
cnsql.ConnectionString = "Data Source=ced2; User ID=sa;
Password=;Initial Catalog=NGN;Persist Security Info=True;"
Dim cmdsql1 As New SqlClient.SqlCommand
Dim i As Integer
Dim j As Integer
cnsql.Open()
cmdsql1.Parameters.Clear()
cmdsql1.CommandText = "insert into MAGAZZINI_SELEZIONATI
(magazzino,utente) values(@magaz,@utente)"
cmdsql1.Connection = cnsql
cmdsql1.Parameters.Add("@Magaz", SqlDbType.NVarChar, 50)
cmdsql1.Parameters.Add("@Utente", SqlDbType.NVarChar, 50)
For i = 0 To Magazzini.Length - 1
cmdsql1.Parameters("@Magaz").Value = Magazzini(i)
cmdsql1.Parameters("@Utente").Value = Me.Utente
cmdsql1.ExecuteNonQuery()
Next i
cnsql.Close()
cmdSql = Nothing
------------------------------------------------------------------------------
Magazzini is an array of strings. If I execute this code in run mode
insert fails and table Magazzini_Selezionati is empty. Code does not
return any error but insert not works. If I execute this code step by
step in debug mode it works right and rows have been inserted into the
table.
Could you tell me why???
I'm working with VS2003, .NET 1.1 SP1 and SQL SERVER 2K SP4.
Thanks in advance
Antonio.
-----------------------------------------------------------------------------
Dim cnsql As New SqlClient.SqlConnection
cnsql.ConnectionString = "Data Source=ced2; User ID=sa;
Password=;Initial Catalog=NGN;Persist Security Info=True;"
Dim cmdsql1 As New SqlClient.SqlCommand
Dim i As Integer
Dim j As Integer
cnsql.Open()
cmdsql1.Parameters.Clear()
cmdsql1.CommandText = "insert into MAGAZZINI_SELEZIONATI
(magazzino,utente) values(@magaz,@utente)"
cmdsql1.Connection = cnsql
cmdsql1.Parameters.Add("@Magaz", SqlDbType.NVarChar, 50)
cmdsql1.Parameters.Add("@Utente", SqlDbType.NVarChar, 50)
For i = 0 To Magazzini.Length - 1
cmdsql1.Parameters("@Magaz").Value = Magazzini(i)
cmdsql1.Parameters("@Utente").Value = Me.Utente
cmdsql1.ExecuteNonQuery()
Next i
cnsql.Close()
cmdSql = Nothing
------------------------------------------------------------------------------
Magazzini is an array of strings. If I execute this code in run mode
insert fails and table Magazzini_Selezionati is empty. Code does not
return any error but insert not works. If I execute this code step by
step in debug mode it works right and rows have been inserted into the
table.
Could you tell me why???
I'm working with VS2003, .NET 1.1 SP1 and SQL SERVER 2K SP4.
Thanks in advance
Antonio.