Hola
Lo que pasa es que esta generando error al tratar de cargar un registro desde el web form, me señala que al parecer es por un item de DropDownList ya que no lo cargo como los otros que los llamo desde las tablas sino que lo deje como item.
Imports System.Data.SqlClient
Imports System.Text
Imports System.Data
...
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.lblAviso.Text = ""
'
Using cnn As New SqlConnection(Me.sdsRegistroPerro.ConnectionString )
' Usamos el comando Insert del DataSource
Dim cmd As New SqlCommand(Me.sdsRegistroPerro.InsertCommand, cnn)
'Dim cmd As New SqlCommand(Me.SqlDataSource2.InsertCommand, cnn)
' Abrimos la conexión
cnn.Open()
...
cmd.Parameters.AddWithValue("@SexoAnimal_P", ddlSexoP.SelectedItem.Text)
cmd.Parameters.AddWithValue("@Tamaño_P", ddlTamaño.SelectedValue)
cmd.Parameters.AddWithValue("@Observaciones_P", txtNotasP.Text)
cmd.Parameters.AddWithValue("@Foto_Perro", fupFotoP.FileBytes)
cmd.ExecuteScalar()
End Using
utilizo ExecuteScalar pues manejo un campo autonumerico
En los tipos de valores tengo : SexoAnimal_P--->nvarchar(100)
Utilizo un SqlDataSource
INSERT ..SexoAnimal_P, ...
UPDATE ..SexoAnimal_P = @SexoAnimal_P, ...
INSERT INTO SexoAnimal_P, ...VALUES ...@SexoAnimal_P,...
El error que me aparece es:
The column name 'Caracter_Perro' is specified more than once in the SET clause. A column cannot be assigned more than one value in the same SET clause. Modify the SET clause to make sure that a column is updated only once. If the SET clause updates columns of a view, then the column name 'Caracter_Perro' may appear twice in the view definition.
Source Error:
Line 38: ' Ejecutamos el comando de inserción
Line 39:
Line 40: cmd.ExecuteScalar()
Line 41: 'cnn.Open()
Line 42: ' Al salir del bloque Using se cierra la conexión
Stack Trace:
[SqlException (0x80131904): The column name 'Caracter_Perro' is specified more than once in the SET clause. A column cannot be assigned more than one value in the same SET clause. Modify the SET clause to make sure that a column is updated only once. If the SET clause updates columns of a view, then the column name 'Caracter_Perro' may appear twice in the view definition.]
System.Data.SqlClient.SqlConnection.OnError(SqlExc eption exception, Boolean breakConnection) +2073486
System.Data.SqlClient.SqlInternalConnection.OnErro r(SqlException exception, Boolean breakConnection) +5064444
System.Data.SqlClient.TdsParser.ThrowExceptionAndW arning() +234
System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) +2275
System.Data.SqlClient.SqlDataReader.ConsumeMetaDat a() +33
System.Data.SqlClient.SqlDataReader.get_MetaData() +86
System.Data.SqlClient.SqlCommand.FinishExecuteRead er(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +311
System.Data.SqlClient.SqlCommand.RunExecuteReaderT ds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async) +987
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result) +162
System.Data.SqlClient.SqlCommand.RunExecuteReader( CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +32
System.Data.SqlClient.SqlCommand.ExecuteScalar() +139
BDACAA_FUNDACION_SEGURO_Admon_Consola_Funda.Button 1_Click(Object sender, EventArgs e) in C:\Users\Maru\Documents\Visual Studio 2010\WebSites\SCAPTAC\BDACAA\BDACAA_SEGURO\FUNDACI ON_SEGURO\Admon_Consola_Funda.aspx.vb:40
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563
no se en donde esta el error acudo a los expertos, no entiendo porque me cargan todos los campos menos ese que esta por items.
Agradesco su colaboración...