Il codice non funziona

martedì 06 dicembre 2005 - 10.05

diegoooo82 Profilo | Junior Member

Qualcuno puo dare un occhiata a questo codice??
perche non mi va?

Public Function Insert(ByVal CodArt As String, ByVal desArt As String, ByVal DesSup As String, ByVal UnMis As String, ByVal CodPro As String, ByVal Rubricaz As String, ByVal codIva As String) As Integer
Dim cn As New SqlConnection(My.Settings.MyConnectionString)
Adapter = New SqlDataAdapter
Me.Adapter.InsertCommand = New SqlCommand
Me.Adapter.InsertCommand.Connection = cn
Me.Adapter.InsertCommand.CommandText = "INSERT INTO [dbo].[Articoli] ([CodArt], [desArt], [DesSup], [UnMis], [CodPro], [R" & _
"ubricaz], [codIva]) VALUES (@CodArt, @desArt, @DesSup, @UnMis, @CodPro, @Rubrica" & _
"z, @codIva)"
Me.Adapter.InsertCommand.CommandType = System.Data.CommandType.Text
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CodArt", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "CodArt", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@desArt", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "desArt", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@DesSup", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "DesSup", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@UnMis", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "UnMis", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@CodPro", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "CodPro", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Rubricaz", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "Rubricaz", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
Me.Adapter.InsertCommand.Parameters.Add(New System.Data.SqlClient.SqlParameter("@codIva", System.Data.SqlDbType.NVarChar, 0, System.Data.ParameterDirection.Input, 0, 0, "codIva", System.Data.DataRowVersion.Current, False, Nothing, "", "", ""))
If (CodArt Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(0).Value = System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(0).Value = CType(CodArt, String)
End If
If (desArt Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(1).Value = System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(1).Value = CType(desArt, String)
End If
If (DesSup Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(2).Value = System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(2).Value = CType(DesSup, String)
End If
If (UnMis Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(3).Value = System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(3).Value = CType(UnMis, String)
End If
If (CodPro Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(4).Value = System.DBNull.Value
Else
Me.Adapter.InsertCommand.Parameters(4).Value = CType(CodPro, String)
End If
If (Rubricaz Is Nothing) Then
Me.Adapter.InsertCommand.Parameters(5).Value = System.DBNull.Value
Else
Me.Adapter.

diegoooo82 Profilo | Junior Member

ce l'ho fatta!!

Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2023
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5