Click here to Skip to main content
15,897,371 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionBinding Controls at run time Pin
ejaz_pk20-Aug-07 11:48
ejaz_pk20-Aug-07 11:48 
AnswerRe: Binding Controls at run time Pin
Christian Graus20-Aug-07 12:15
protectorChristian Graus20-Aug-07 12:15 
QuestionChange the image on a button Pin
rnamro20-Aug-07 10:40
rnamro20-Aug-07 10:40 
AnswerRe: Change the image on a button Pin
Michael Sync20-Aug-07 17:44
Michael Sync20-Aug-07 17:44 
GeneralRe: Change the image on a button [modified] Pin
rnamro21-Aug-07 6:13
rnamro21-Aug-07 6:13 
GeneralRe: Change the image on a button Pin
Michael Sync21-Aug-07 15:13
Michael Sync21-Aug-07 15:13 
AnswerRe: Change the image on a button Pin
TomGarth21-Aug-07 13:07
TomGarth21-Aug-07 13:07 
QuestionHow to loop thru a datagrid to get difference for each record Pin
Smokeywade20-Aug-07 10:40
Smokeywade20-Aug-07 10:40 
Basically what I want to do is - subtract a time record from my system time and place that result into a dynamic column for each record. I'm definetly having problems with my loop and the loop syntax - help will be greatly appreciated.

With the code below I get an error system.InvalidCastException: Invalid cast from Int32 to DateTime.
at System.Int32.System.Iconvertible.TODateTime(IFormat Provide provider)
at System.Convert.ToDateTime(Object Value)
at System.Data.Common.dateTimeStorage.set(Int32 record, Object value)
at System.Data.dataColumn.set_Item(Int32 record, Object value) Couldnt stor <0> in requested_date Column. Expected type is DatTime.

When I change the for loop around a just a littile I will get the difference of time for just the first record...Thanks
Here is my code:


Public Sub frmLoad()
Dim i As Integer
Dim MyDataSet As New DataSet
Dim command1 As New SqlCommand("Select * FROM LateOrders_query_view order by reason", cnn1)
Dim SqlReader As SqlDataReader
Try
cnn1.Open()
'Debug.WriteLine(cnn1.ConnectionString)
Dim dt As New DataTable("LateOrders_query_view")
dgOrderReport.DataSource = dt
Dim DirAdapter As New SqlDataAdapter(command1)
DirAdapter.Fill(MyDataSet, "LateOrders_query_view")
dgOrderReport.DataSource = MyDataSet.Tables("LateOrders_query_view").DefaultView


Dim dc As DataColumn
dc = New DataColumn("Days Late") ', Type.GetType("System.double"))
MyDataSet.Tables(0).Columns.Add(dc)
dayslate()

Dim array As Array
Dim cntr As Integer

'Loop thru each record calculate time difference
For i = 0 To MyDataSet.Tables(0).Rows.Count - 1
MyDataSet.Tables(0).Rows(i).Item(3) = 0
'array(cntr) = MyDataSet.Tables(0).Rows(i).Item(3)
'Get Results place into Column "Days Late"

dc.Expression = DateDiff("d", dgOrderReport.Item(dgOrderReport.CurrentRowIndex, 3), System.DateTime.Today)
Next


Dim tblSetting As New DataGridTableStyle
tblSetting = New DataGridTableStyle

With dgOrderReport
'.SetDataBinding(MyDataSet, "LateOrders_query_view")
' .BackgroundColor = System.Drawing.Color.Lavender
' Set DataGrid Caption Background Color
.CaptionBackColor = System.Drawing.Color.SlateBlue
' Set DataGrid Caption Foreground Color
' .CaptionForeColor = System.Drawing.Color.LemonChiffon
' Set DataGrid Parent Rows Background Color
'.ParentRowsBackColor = System.Drawing.Color.Lavender
' Set DataGrid Parent Rows Foreground Color
' .ParentRowsForeColor = System.Drawing.Color.SlateBlue
.CaptionText = "Late Order Report"
.TableStyles.Clear()
End With
tblSetting.MappingName = MyDataSet.Tables(0).ToString()
dgOrderReport.TableStyles.Add(tblSetting)

settings()


Catch ex As Exception
MsgBox(ex.Message)
End Try
cnn1.Close()
End Sub


-- modified at 11:41 Tuesday 21st August, 2007

Thanks

QuestionVB excel autofilter Help Pin
VBHelpIsNeeded20-Aug-07 9:56
VBHelpIsNeeded20-Aug-07 9:56 
QuestionEASY SIMPLE, Never done keypress, help.... Pin
Joey Picerno20-Aug-07 9:15
Joey Picerno20-Aug-07 9:15 
AnswerRe: EASY SIMPLE, Never done keypress, help.... Pin
nlarson1120-Aug-07 16:55
nlarson1120-Aug-07 16:55 
GeneralRe: EASY SIMPLE, Never done keypress, help.... Pin
Joey Picerno21-Aug-07 3:02
Joey Picerno21-Aug-07 3:02 
QuestionEncryption Pin
Dominick Marciano20-Aug-07 7:15
professionalDominick Marciano20-Aug-07 7:15 
AnswerRe: Encryption Pin
Mark Churchill20-Aug-07 21:39
Mark Churchill20-Aug-07 21:39 
QuestionHow to avoid html tag in body of mail while saving to db. [modified] Pin
rahul.net1120-Aug-07 5:12
rahul.net1120-Aug-07 5:12 
AnswerRe: How to avoid html tag in body of mail while saving to db. Pin
nlarson1120-Aug-07 17:00
nlarson1120-Aug-07 17:00 
Questionhelp Pin
padbindu20-Aug-07 4:06
padbindu20-Aug-07 4:06 
AnswerRe: help Pin
Christian Graus20-Aug-07 12:17
protectorChristian Graus20-Aug-07 12:17 
QuestionHelp with aScheduling grid/Table Pin
Mr Oizo20-Aug-07 2:07
Mr Oizo20-Aug-07 2:07 
AnswerRe: Help with aScheduling grid/Table Pin
Johan Hakkesteegt31-Aug-07 3:01
Johan Hakkesteegt31-Aug-07 3:01 
QuestionHow to write to new line using streamwriter. Pin
rahul.net1120-Aug-07 1:49
rahul.net1120-Aug-07 1:49 
AnswerRe: How to write to new line using streamwriter. Pin
Rami Said Abd Alhalim20-Aug-07 2:21
Rami Said Abd Alhalim20-Aug-07 2:21 
GeneralRe: How to write to new line using streamwriter. Pin
Rami Said Abd Alhalim20-Aug-07 2:25
Rami Said Abd Alhalim20-Aug-07 2:25 
GeneralRe: How to write to new line using streamwriter. Pin
rahul.net1120-Aug-07 4:32
rahul.net1120-Aug-07 4:32 
AnswerRe: How to write to new line using streamwriter. Pin
Rupesh Kumar Swami20-Aug-07 2:28
Rupesh Kumar Swami20-Aug-07 2:28 

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.