Click here to Skip to main content
15,887,027 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralSaving Data Pin
tibmark4-Apr-08 7:23
tibmark4-Apr-08 7:23 
GeneralRe: Saving Data Pin
Dave Kreskowiak4-Apr-08 8:12
mveDave Kreskowiak4-Apr-08 8:12 
GeneralRe: Saving Data Pin
tibmark4-Apr-08 8:19
tibmark4-Apr-08 8:19 
GeneralRe: Saving Data Pin
Dave Kreskowiak4-Apr-08 9:36
mveDave Kreskowiak4-Apr-08 9:36 
GeneralRe: Saving Data Pin
jzonthemtn4-Apr-08 8:33
jzonthemtn4-Apr-08 8:33 
GeneralRe: Saving Data Pin
tibmark4-Apr-08 8:40
tibmark4-Apr-08 8:40 
GeneralRe: Saving Data Pin
A Wong4-Apr-08 8:57
A Wong4-Apr-08 8:57 
GeneralVB.net/excel/access - problem with strings and dates Pin
AHeavey4-Apr-08 6:59
AHeavey4-Apr-08 6:59 
I am having trouble figuring out how to validate some dates. I have to read them in from an excel file and put the into access. The problem is if a null value is entered for a date in the excel file. null values are allowed int the db but I can't pass them through my "insert command". Any suggestions?
All help is welcome
Insert code below:

Sub IncidentReportAdd(ByVal IncNo As String, ByVal IncType As String, ByVal estate As String, _
ByVal MTI As System.DateTime, ByVal INATT As System.DateTime, _
ByVal stopTime As System.DateTime, ByVal MAV As System.DateTime, ---etc....)

Dim cmd As OleDbCommand = New OleDbCommand()
Dim paramContNo As New OleDbParameter()
Dim paramIncDescription As New OleDbParameter()
Dim paramAdd1 As New OleDbParameter()
etc...

With paramContNo
.ParameterName = "ContNo"
.OleDbType = OleDbType.Double
.Size = 4
.Value = splitCont.GetValue(1)
End With
cmd.Parameters.Add(paramContNo)

With paramTimeStop
.ParameterName = "Stop"
.OleDbType = OleDbType..Value = stopTime
End With
cmd.Parameters.Add(paramTimeStop)

Dim param As OleDbParameter
For Each param In cmd.Parameters
If param.OleDbType = OleDbType.VarChar Then
If param.Value = "" Then
param.Value = "null"
End If
End If
Next
'execute command
cmd.CommandText = "EXECUTE ActivityBufferInsert"
con.Open()
cmd.ExecuteNonQuery()
con.Close()

>>
>>the code is called here:
>>

MyConnection = New System.Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;" _
& "data source=" & e.FullPath & "; " & "Extended Properties=Excel 8.0;")
Dim DtSet As New DataSet
Dim MyCommand As System.Data.OleDb.OleDbDataAdapter
' Select the data from Sheet1 of the workbook.
MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [sheet1$]", MyConnection)
MyCommand.Fill(DtSet, "ExcelFields")
MyConnection.Close()
Dim ir As New DBTier
Dim dr As DataRow
For Each dr In DtSet.Tables("ExcelFields").Rows()
ir.IncidentReportAdd(dr.ItemArray(0).ToString(), dr.ItemArray(1).ToString(), _
dr.ItemArray(5).ToString(), dr.ItemArray(7).ToString(), dr.ItemArray(2).ToString(), _
dr.ItemArray(8).ToString(), dr.ItemArray(10).ToString(), dr.ItemArray(12).ToString(), _
Date.Parse(dr.ItemArray(13).ToString()), Date.Parse(dr.ItemArray(14).ToString()), _
Date.Parse(dr.ItemArray(15).ToString()), Date.Parse(dr.ItemArray(16).ToString()), _
Date.Parse(dr.ItemArray(18).ToString()), Date.Parse(dr.ItemArray(19).ToString()), _
dr.ItemArray(21).ToString())
Next


I know it's a lot to read through but any help would be greatly appreciated.
GeneralRe: VB.net/excel/access - problem with strings and dates Pin
Dave Kreskowiak4-Apr-08 8:08
mveDave Kreskowiak4-Apr-08 8:08 
Generalapplication created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 4:29
Chun24-Apr-08 4:29 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Dave Kreskowiak4-Apr-08 5:08
mveDave Kreskowiak4-Apr-08 5:08 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 5:36
Chun24-Apr-08 5:36 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Dave Kreskowiak4-Apr-08 5:57
mveDave Kreskowiak4-Apr-08 5:57 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! [modified] Pin
Chun24-Apr-08 6:41
Chun24-Apr-08 6:41 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Dave Kreskowiak4-Apr-08 7:47
mveDave Kreskowiak4-Apr-08 7:47 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! [modified] Pin
Chun24-Apr-08 8:22
Chun24-Apr-08 8:22 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Dave Kreskowiak4-Apr-08 8:35
mveDave Kreskowiak4-Apr-08 8:35 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 8:42
Chun24-Apr-08 8:42 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 9:52
Chun24-Apr-08 9:52 
QuestionRe: application created on vista using vb.net does not run on my xp computer!! Pin
Steven J Jowett4-Apr-08 5:39
Steven J Jowett4-Apr-08 5:39 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 5:43
Chun24-Apr-08 5:43 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
jzonthemtn4-Apr-08 8:37
jzonthemtn4-Apr-08 8:37 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
Chun24-Apr-08 8:46
Chun24-Apr-08 8:46 
GeneralRe: application created on vista using vb.net does not run on my xp computer!! Pin
KrisnNala4-Apr-08 22:26
KrisnNala4-Apr-08 22:26 
GeneralHelp in getting the IP address dynamically Pin
aaraaayen4-Apr-08 1:24
aaraaayen4-Apr-08 1:24 

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.