Click here to Skip to main content
16,005,141 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: MDI Applications on VB .NET Pin
Dave Kreskowiak18-Jul-07 2:09
mveDave Kreskowiak18-Jul-07 2:09 
QuestionReflection on a Collection Object Pin
twista17-Jul-07 13:27
twista17-Jul-07 13:27 
QuestionVB.NET Web Services question Pin
Subrat Parida17-Jul-07 13:00
Subrat Parida17-Jul-07 13:00 
AnswerRe: VB.NET Web Services question Pin
_Damian S_17-Jul-07 15:26
professional_Damian S_17-Jul-07 15:26 
GeneralRe: VB.NET Web Services question Pin
Subrat Parida18-Jul-07 9:38
Subrat Parida18-Jul-07 9:38 
GeneralRe: VB.NET Web Services question Pin
Dave Kreskowiak18-Jul-07 11:40
mveDave Kreskowiak18-Jul-07 11:40 
GeneralRe: VB.NET Web Services question Pin
Subrat Parida18-Jul-07 15:06
Subrat Parida18-Jul-07 15:06 
Questionwhy no delete? Pin
boyindie17-Jul-07 12:34
boyindie17-Jul-07 12:34 
Hi I have writing the followin function which catches a datagrid link button event, which should take the user id from the selected record and pass it into a stored procedure, and then refresh page, with the selected record deleted.

It all seems to work perfectly fine, but it jus doesn't delete for the some reason

I have also ran the procedure through a command window and that works as expected

here is my code for dealing with the button click and passing the parameter into the stored procedure

any help or spotting of my retarded mistake would be much appreciated

cheers
boyindie

Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As DataGridItemEventArgs) Handles dgPriv.ItemDataBound
Dim l As LinkButton
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
l = CType(e.Item.Cells(6).FindControl("cmdDel"), LinkButton)
l.Attributes.Add("onclick", "return confirm('Are you sure you want to delete this item?');")
End If
End Sub

Sub dgpriv_ItemCommand(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles dgPriv.ItemCommand

Dim iid As Integer = dgPriv.DataKeys(e.Item.ItemIndex) 'Grab the ID from the hidden column
Dim litErr As New Literal
Dim myConnection As New MySqlConnection("Server=localhost; ;database=test;")
Try

Dim param As New MySqlParameter
Dim myDeleteCommand As MySqlCommand = New MySqlCommand("sp_mydelete", myConnection)
myDeleteCommand.CommandType = CommandType.StoredProcedure

param = myDeleteCommand.Parameters.Add("?p_id", MySqlDbType.VarChar)
param.Direction = ParameterDirection.Input
param.Value = iid


myConnection.Open() 'Open the connection
myDeleteCommand.ExecuteNonQuery() 'Delete the record
myConnection.Close() 'Close the connection

Catch ex As Exception
litErr.Text = ex.Message
MsgBox(ex.Message)
End Try

refresh()
End Sub

and this is my asp code

<asp:datagrid id="dgPriv" runat="server" BorderWidth="0"
CellPadding="4" Width="100%"
Font-Size="Smaller"
HeaderStyle-HorizontalAlign="Center"
HeaderStyle-Font-Bold="True"
datakeyfield ="userId"
HeaderStyle-BackColor="Navy"
HeaderStyle-ForeColor="White"
AlternatingItemStyle-BackColor="ActiveBorder" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn DataField ="userId" HeaderText="User ID"></asp:BoundColumn>
<asp:BoundColumn DataField ="username" HeaderText="User Name"></asp:BoundColumn>
<asp:BoundColumn DataField ="user_firstName" HeaderText="First Name"></asp:BoundColumn>
<asp:BoundColumn DataField ="user_lastname" HeaderText="Last Name"></asp:BoundColumn>
<asp:BoundColumn DataField ="groups" HeaderText="Privelages"></asp:BoundColumn>
<asp:BoundColumn DataField ="joinDate" HeaderText="Date Registered"></asp:BoundColumn>

<asp:TemplateColumn HeaderText="Delete User">
<ItemTemplate >
<asp:linkbutton id="cmdDel" runat="server">Delete</asp:linkbutton>
</ItemTemplate></asp:TemplateColumn>
</Columns>
<PagerStyle HorizontalAlign="Left" />
<AlternatingItemStyle BackColor="ActiveBorder" />
<HeaderStyle BackColor="Navy" Font-Bold="True" ForeColor="White" HorizontalAlign="Center" />

</asp:datagrid>
</div>
</form>


AnswerRe: why no delete? Pin
RepliCrux17-Jul-07 13:11
RepliCrux17-Jul-07 13:11 
GeneralRe: why no delete? Pin
boyindie17-Jul-07 13:20
boyindie17-Jul-07 13:20 
GeneralRe: why no delete? Pin
boyindie17-Jul-07 13:23
boyindie17-Jul-07 13:23 
QuestionDatabase permissions Pin
Cory Kimble17-Jul-07 10:43
Cory Kimble17-Jul-07 10:43 
AnswerRe: Database permissions Pin
Dave Kreskowiak17-Jul-07 11:05
mveDave Kreskowiak17-Jul-07 11:05 
AnswerRe: Database permissions Pin
leckey17-Jul-07 11:20
leckey17-Jul-07 11:20 
GeneralRe: Database permissions Pin
Cory Kimble18-Jul-07 3:13
Cory Kimble18-Jul-07 3:13 
GeneralRe: Database permissions Pin
Dave Kreskowiak18-Jul-07 11:42
mveDave Kreskowiak18-Jul-07 11:42 
QuestionByRef in class property setters Pin
Ahmad Zaidi17-Jul-07 9:16
Ahmad Zaidi17-Jul-07 9:16 
AnswerRe: ByRef in class property setters Pin
Dave Kreskowiak17-Jul-07 10:15
mveDave Kreskowiak17-Jul-07 10:15 
AnswerRe: ByRef in class property setters Pin
Guffa17-Jul-07 11:45
Guffa17-Jul-07 11:45 
AnswerRe: ByRef in class property setters Pin
Ahmad Zaidi17-Jul-07 22:26
Ahmad Zaidi17-Jul-07 22:26 
QuestionWindows service using webclient and Javascript Pin
Manuel F. Hernandez17-Jul-07 9:10
Manuel F. Hernandez17-Jul-07 9:10 
QuestionHelp with populating data sets Pin
iain659417-Jul-07 6:22
iain659417-Jul-07 6:22 
AnswerRe: Help with populating data sets Pin
originSH17-Jul-07 6:26
originSH17-Jul-07 6:26 
QuestionRe: Help with populating data sets Pin
iain659417-Jul-07 23:11
iain659417-Jul-07 23:11 
AnswerRe: Help with populating data sets Pin
Dave Kreskowiak18-Jul-07 2:08
mveDave Kreskowiak18-Jul-07 2:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.