Click here to Skip to main content
15,923,273 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: CINT Pin
tatchung7-Sep-05 20:04
tatchung7-Sep-05 20:04 
GeneralRe: CINT Pin
Dave Kreskowiak8-Sep-05 1:56
mveDave Kreskowiak8-Sep-05 1:56 
Answer[Message Deleted] Pin
Steve Pullan7-Sep-05 19:05
Steve Pullan7-Sep-05 19:05 
QuestionChange Font map on windows Pin
dmtuan7-Sep-05 17:15
dmtuan7-Sep-05 17:15 
QuestionRichTextBox FontStyles Pin
Taen_Karth7-Sep-05 15:23
Taen_Karth7-Sep-05 15:23 
AnswerRe: RichTextBox FontStyles Pin
Taen_Karth7-Sep-05 15:59
Taen_Karth7-Sep-05 15:59 
Questionsome guidance in making project setup Pin
monica2k7-Sep-05 14:39
monica2k7-Sep-05 14:39 
QuestionHow to delete a row from a datagrid:-( Pin
macupryk7-Sep-05 14:38
macupryk7-Sep-05 14:38 
I have the following two functions. My goal is to highlight a row in a
datagrid and delete a row. Problem arises when I click on the delete button.
Below are two sub routines for DoDelete. Which route should I go with?
I have created stored procedure for deleting the row as well.
Any help would be greatful.


Private Sub highLightRow(ByVal sender As Object, ByVal e As MouseEventArgs)

Dim pt = New Point(e.X, e.Y)
Dim grd As DataGrid = CType(sender, DataGrid)
Dim hit As DataGrid.HitTestInfo = grd.HitTest(pt)


If hit.Type = grd.HitTestType.Cell Then
grd.CurrentCell = New DataGridCell(hit.Row, hit.Column)
RowNum = hit.Row
grd.Select(RowNum)

PolicyNumber = Convert.ToString(grd.Item(RowNum, 1))
TransCodeOrig = Convert.ToString(grd.Item(RowNum, 2))
TransEffDate = Convert.ToString(grd.Item(RowNum, 3))
ModifiedUID = Convert.ToString(grd.Item(RowNum, 7))
End If
End Sub


Public Sub DoDelete()
Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember)
Dim dr As DataRow = CType(bm.Current, DataRowView).Row
Try
PolicyNumber = dr(1)
TransCodeOrig = dr(2)
TransEffDate = dr(3)
ModifiedUID = dr(7)
dr.Delete()
DsTransOverride1.dbo_stp_SelTransOverrides.Clear()
SqlDataAdapter1.Fill(DsTransOverride1.dbo_stp_SelTransOverrides)
' SqlDataAdapter1.Update(Me.DsTransOverride1, "dbo_stp_SelTransOverrides")
DsTransOverride1.dbo_stp_SelTransOverrides.AcceptChanges()
Me.lbNumRec.Text = Me.DsTransOverride1.Tables(0).Rows.Count.ToString()
Catch exError As Exception
MessageBox.Show(exError.Message)
End Try
End Sub

Public Sub doDelete()
' MDI Main Delete record requ3est toolbar button pressed
'if no records are displayed on the grid exist then exit
Dim ConnectionString As String = System.Configuration.ConfigurationSettings.AppSettings("FinSolMainDBConn")
Dim connfinsol As New System.Data.SqlClient.SqlConnection(ConnectionString)
Dim myCommand As New SqlCommand("stp_DelTransOverride ", connfinsol)
myCommand.CommandType = CommandType.StoredProcedure

'Add Parameters
' 1 Policy Number
myCommand.Parameters.Add("@Policy_Nbr", SqlDbType.VarChar, 7).Value = PolicyNumber

' 2 Original Tranaction Override
myCommand.Parameters.Add("@Trans_CodeOrig", SqlDbType.VarChar, 6).Value = TransCodeOrig

' 3 Transaction Effective Date
myCommand.Parameters.Add("@Trans_Eff_Date", SqlDbType.DateTime, 8).Value = TransEffDate

' 8 Modified UID
myCommand.Parameters.Add("@ModifiedUID", SqlDbType.NVarChar, 48).Value = ModifiedUID

'Open Connection
Try
'Open Connection
connfinsol.Open()
myCommand.ExecuteNonQuery()
MsgBox("Data Deleted Successfully !", MsgBoxStyle.Information, Me.Text)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, Me.Text)
Finally
If myCommand.Connection.State = ConnectionState.Open Then
myCommand.Connection.Close()
End If
End Try

End Sub
I am not sure where to go, which DoDelete do go with.


Any help would be appreciated.
AnswerRe: How to delete a row from a datagrid:-( Pin
mcgann8-Sep-05 4:54
mcgann8-Sep-05 4:54 
QuestionOdbc Parameter error Pin
Mark067-Sep-05 11:53
Mark067-Sep-05 11:53 
QuestionOutlook Mapi older failure Pin
Member 20812627-Sep-05 10:53
Member 20812627-Sep-05 10:53 
QuestionForm Height Pin
No-e7-Sep-05 5:31
No-e7-Sep-05 5:31 
AnswerRe: Form Height Pin
Dave Kreskowiak7-Sep-05 5:39
mveDave Kreskowiak7-Sep-05 5:39 
GeneralRe: Form Height Pin
No-e7-Sep-05 5:45
No-e7-Sep-05 5:45 
QuestionHow do you hide a tabPage within a tabcontrol Pin
directred7-Sep-05 4:06
directred7-Sep-05 4:06 
AnswerRe: How do you hide a tabPage within a tabcontrol Pin
rwestgraham7-Sep-05 11:15
rwestgraham7-Sep-05 11:15 
GeneralRe: How do you hide a tabPage within a tabcontrol Pin
directred8-Sep-05 4:23
directred8-Sep-05 4:23 
GeneralRe: How do you hide a tabPage within a tabcontrol Pin
KaptinKrunch8-Sep-05 8:15
KaptinKrunch8-Sep-05 8:15 
GeneralRe: How do you hide a tabPage within a tabcontrol Pin
rwestgraham9-Sep-05 10:05
rwestgraham9-Sep-05 10:05 
QuestionSorting........ Pin
daviiie7-Sep-05 2:09
daviiie7-Sep-05 2:09 
AnswerRe: Sorting........ Pin
Colin Angus Mackay7-Sep-05 10:42
Colin Angus Mackay7-Sep-05 10:42 
QuestionDisable Insert in Datagrid Pin
Tim Emjay7-Sep-05 1:54
Tim Emjay7-Sep-05 1:54 
AnswerRe: Disable Insert in Datagrid Pin
_mubashir7-Sep-05 5:31
_mubashir7-Sep-05 5:31 
GeneralRe: Disable Insert in Datagrid Pin
Tim Emjay7-Sep-05 6:02
Tim Emjay7-Sep-05 6:02 
QuestionForm TextBox query Pin
directred7-Sep-05 0:59
directred7-Sep-05 0:59 

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.