delete and update data from a datagrid (vb asp.net)

J

John Smith

http://www.aspnet101.com/aspnet101/aspnet/codesample.aspx?code=delsample

I need exactly the same thing seen here but for vb(.net) asp.net page. Also
I have multiple datagrids running off one dataset. When I update something
in one datagrid i want it to display immediately in the datagrid that
specifies another day. eg. i have a schedule set for monday. on the monday
datagrid i update the row and when i select update it should go immediately
to the thursday datagrid.

any help greatly appreciated
cheers
 
C

Cor Ligthert

John,
I need exactly the same thing seen here but for vb(.net) asp.net page.

This is a sample for VBNet asp.net page or do you mean you want this for a
winform or do you mean using VSNet and than create a DLL.

In the last case you can paste the form part in the HTML part from the
webpage in VSNet in the form part between the form tags.

The VBcode goes in the codepart, where you past this code from it in the
load event or delete that one and add after this sub header "handles
mybase.load"

\\\
Sub Page_Load(Source As Object, E As EventArgs)
If Not Page.IsPostBack Then
BindData()
End If
End Sub
///

I hope this helps?

Cor
 
J

John Smith

Ok found some code:
Private Sub dgMonday_DeleteCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
dgMonday.DeleteCommand, dgTuesday.DeleteCommand, dgWednesday.DeleteCommand,
dgThursday.DeleteCommand, dgFriday.DeleteCommand

Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
"Data Source=" & Server.MapPath("/databases/database.mdb")

Dim DeleteCmd As String = "DELETE from Cleaning_Schedule Where Task_ID =
@Task_ID"

Dim MyConn As New OleDbConnection(strConn)

Dim Cmd As New OleDbCommand(DeleteCmd, MyConn)

Cmd.Parameters.Add(New OleDbParameter("@Task_ID",
dgMonday.DataKeys(CInt(e.Item.ItemIndex))))

MyConn.Open()

Cmd.ExecuteNonQuery()

MyConn.Close()

dgMonday.DataBind()



But everytime i run it it says not a valdi filename. arrghh i know the path
is correct what else could it be? a database locking issue?
 
C

Cor Ligthert

John,

I was asking is it for a Winform or for a webform and you did not answer
that, that makes answering really dificult.

Assuming that it is for a webform than can it be that the ASPNET user is not
authorised for this file.

("/databases/database.mdb")

However it stays guessing in this way.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top