Eliminar registros
Necesito eliminar unos registros de una bd de sql server 2005, pero tengo que utilizar un procedimiento almacenado llamandolo desde asp.net
lo que tengo de código es el siguiente:
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter
'Create a connection to the SQL Server.
MyConnection = New SqlConnection("server=SILVER-917C9019\SQLEXPRESS;database=pl0x;uid=Pipo" & ";pwd=123456" & ";")
'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter = New SqlDataAdapter("Eliminar_materia", MyConnection)
'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Id_materia", _
SqlDbType.Int))
'Assign the search value to the parameter.
MyDataAdapter.SelectCommand.Parameters("@Id_materia").Value = TextBox1.Text
'Create and add an output parameter to Parameters collection.
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Eliminando", _
SqlDbType.Char))
'Set the direction for the parameter. This parameter returns the Rows returned.
MyDataAdapter.SelectCommand.Parameters("@Eliminando").Direction = ParameterDirection.Output
...
Ahí me quedé y no le busco por el momento como hacerle...
lo que tengo de código es el siguiente:
Dim DS As DataSet
Dim MyConnection As SqlConnection
Dim MyDataAdapter As SqlDataAdapter
'Create a connection to the SQL Server.
MyConnection = New SqlConnection("server=SILVER-917C9019\SQLEXPRESS;database=pl0x;uid=Pipo" & ";pwd=123456" & ";")
'Create a DataAdapter, and then provide the name of the stored procedure.
MyDataAdapter = New SqlDataAdapter("Eliminar_materia", MyConnection)
'Set the command type as StoredProcedure.
MyDataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure
'Create and add a parameter to Parameters collection for the stored procedure.
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Id_materia", _
SqlDbType.Int))
'Assign the search value to the parameter.
MyDataAdapter.SelectCommand.Parameters("@Id_materia").Value = TextBox1.Text
'Create and add an output parameter to Parameters collection.
MyDataAdapter.SelectCommand.Parameters.Add(New SqlParameter("@Eliminando", _
SqlDbType.Char))
'Set the direction for the parameter. This parameter returns the Rows returned.
MyDataAdapter.SelectCommand.Parameters("@Eliminando").Direction = ParameterDirection.Output
...
Ahí me quedé y no le busco por el momento como hacerle...
1 Respuesta
Respuesta de carloscharly
1