Dim connectionString As String = "server='(local)'; trusted_connection=true; database='Pubs';" 'BD de ejemplo jeje...
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "INSERT INTO [Paises] ([Pais], [CodEnTransportes]) VALUES (@Pais, @CodEnTransporte"& _
"s)"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection
Dim dbParam_pais As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_pais.ParameterName = "@Pais"
dbParam_pais.Value = pais
dbParam_pais.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_pais)
Dim dbParam_codEnTransportes As System.Data.IDataParameter = New System.Data.SqlClient.SqlParameter
dbParam_codEnTransportes.ParameterName = "@CodEnTransportes"
dbParam_codEnTransportes.Value = codEnTransportes
dbParam_codEnTransportes.DbType = System.Data.DbType.String
dbCommand.Parameters.Add(dbParam_codEnTransportes)
Dim rowsAffected As Integer = 0
dbConnection.Open
Try
rowsAffected = dbCommand.ExecuteNonQuery
Finally
dbConnection.Close
End Try