moralju
asked on
DAO in VB.net
I am trying to use DAO in vb.net.. I know I should use ado but after a days worth of work I am going to stick to DAO.
I am having problems making the connection in vb.net
can someone help me fix this code to connect to an access database in vb.net using dao.
thanks
Dim db As dao.database
Dim rs As dao.Recordset
Dim strSQL As String
Dim conn As String
conn.open("Driver={Microso ft Access Driver (*.mdb)};Dbq=D:\Benefits\n arvis.mdb; Uid=admin; Pwd=")
maybe my brain is fried cause I just can't seem to find the answer.
I am having problems making the connection in vb.net
can someone help me fix this code to connect to an access database in vb.net using dao.
thanks
Dim db As dao.database
Dim rs As dao.Recordset
Dim strSQL As String
Dim conn As String
conn.open("Driver={Microso
maybe my brain is fried cause I just can't seem to find the answer.
ASKER
I'm having trouble converting this to ado.net
can you help
Option Explicit
Dim db As Database
Dim rs As Recordset
Dim rst As Recordset
Private Sub Command1_Click()
Dim strID As String
Dim strLname As String
Dim StrFname As String
Dim rcdcnt As Integer
Dim nIndex
Dim nbar
Dim i
Set rs = db.OpenRecordset("Select * from tblagents")
Me.ctSchedule0.DateStart = 38215
ctSchedule0.AddColumn "Agent ID", 50
ctSchedule0.AddColumn "Last", 100
ctSchedule0.AddColumn "First", 100
Me.ctSchedule0.TimeType = 3
While Not rs.EOF
Set rst = db.OpenRecordset("select * from tblTransactions where agent_id = " & rs!agent_id)
strID = rs!agent_id
strLname = rs!l_name
StrFname = rs!f_name
nIndex = Me.ctSchedule0.AddItem(str ID + ";" + strLname + ";" + StrFname)
If rst.RecordCount <> 0 Then
rst.MoveLast
rst.MoveFirst
End If
rcdcnt = rst.RecordCount
For i = 1 To rcdcnt
nbar = Me.ctSchedule0.AddTimeBar( nIndex, rst!TimeStart, rst!TimeEnd, rst!Date, rst!Date)
rst.MoveNext
Next i
rs.MoveNext
Wend
End Sub
Private Sub Form_Load()
' Make sure your database file is with the same folder as your app resides.
Set db = DBEngine.Workspaces(0).Ope nDatabase( App.Path & "\narvis.mdb", False, False)
End Sub
can you help
Option Explicit
Dim db As Database
Dim rs As Recordset
Dim rst As Recordset
Private Sub Command1_Click()
Dim strID As String
Dim strLname As String
Dim StrFname As String
Dim rcdcnt As Integer
Dim nIndex
Dim nbar
Dim i
Set rs = db.OpenRecordset("Select * from tblagents")
Me.ctSchedule0.DateStart = 38215
ctSchedule0.AddColumn "Agent ID", 50
ctSchedule0.AddColumn "Last", 100
ctSchedule0.AddColumn "First", 100
Me.ctSchedule0.TimeType = 3
While Not rs.EOF
Set rst = db.OpenRecordset("select * from tblTransactions where agent_id = " & rs!agent_id)
strID = rs!agent_id
strLname = rs!l_name
StrFname = rs!f_name
nIndex = Me.ctSchedule0.AddItem(str
If rst.RecordCount <> 0 Then
rst.MoveLast
rst.MoveFirst
End If
rcdcnt = rst.RecordCount
For i = 1 To rcdcnt
nbar = Me.ctSchedule0.AddTimeBar(
rst.MoveNext
Next i
rs.MoveNext
Wend
End Sub
Private Sub Form_Load()
' Make sure your database file is with the same folder as your app resides.
Set db = DBEngine.Workspaces(0).Ope
End Sub
Sure.. I'll try...
first what these things are doing ? (In plain words)
>> nIndex = Me.ctSchedule0.AddItem(str ID + ";" + strLname + ";" + StrFname)
>> nbar = Me.ctSchedule0.AddTimeBar( nIndex, rst!TimeStart, rst!TimeEnd, rst!Date, rst!Date)
and if possible, please explain your task .. :))
-Baan
first what these things are doing ? (In plain words)
>> nIndex = Me.ctSchedule0.AddItem(str
>> nbar = Me.ctSchedule0.AddTimeBar(
and if possible, please explain your task .. :))
-Baan
ASKER
I have a control http://www.dbi-tech.com/SolSched7ProductPage.htm that I've been using in VB6 and MS access for a while now..
I am switching over to vb.net and I'm having trouble loading the data to the control.
the additem method nIndex = ctSchedule.AddItem("text") load the list of agents and the nindex is the index it was loaded to kinda like a listbox.
the addtimebar [form.]ctSchedule.AddTimeB ar( nIndex, lTimeStart, lTimeEnd, lDateStart, lDateEnd ) loads the time bars for each agent
well as you can see in vb6 I looped thru each agent in the agent table. and at the same time looped thru each transaction in the transaction table.
in vb6 it took 1-2 secs to load 4000 transactions
I can't seem to do the same in vb.net
I'm about to crack here.. please help
I am switching over to vb.net and I'm having trouble loading the data to the control.
the additem method nIndex = ctSchedule.AddItem("text")
the addtimebar [form.]ctSchedule.AddTimeB
well as you can see in vb6 I looped thru each agent in the agent table. and at the same time looped thru each transaction in the transaction table.
in vb6 it took 1-2 secs to load 4000 transactions
I can't seem to do the same in vb.net
I'm about to crack here.. please help
ok almost done here... I need to know the data types and the column index of those fields in the "tblTransactions" table
TimeStart, TimeEnd, Date, Date >>> you are inserting the "Date" field twice...
TimeStart, TimeEnd, Date, Date >>> you are inserting the "Date" field twice...
ASKER
I'm adding one bar to the schedule.. each transac is only one day
ASKER
so timestart, timeend, date start ,date end would only add one bar
I need to know the data types of those fields :((
ASKER
If you help.. by gosh I will name my first born after you...
lol... great...
well... you see this line...
nbar = Me.ctSchedule0.AddTimeBar( nIndex, rst!TimeStart, rst!TimeEnd, rst!Date, rst!Date)
~~~~~~ ~~~~~
you are using same field values ... Is that what you want ??
-Baan
well... you see this line...
nbar = Me.ctSchedule0.AddTimeBar(
~~~~~~ ~~~~~
you are using same field values ... Is that what you want ??
-Baan
ASKER
agent id in both tables is datatype long
time start is Integer.. its the number of minutes from midnight so 600 would be 10am
time end is integer.. same as time start
date is long.. the number of days from 01/01/1900 so 38215 would be 08/18/04
time start is Integer.. its the number of minutes from midnight so 600 would be 10am
time end is integer.. same as time start
date is long.. the number of days from 01/01/1900 so 38215 would be 08/18/04
ASKER
I am using the dame value b/c its the date the bar is supposed to start and end.
the transaction table consist of a one transaction per day. so the start date is the same as the end date
the transaction table consist of a one transaction per day. so the start date is the same as the end date
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I am getting a An Unhandled exception of type 'system.indexoutofRangeExc eption' Occusred in system.data.dll
Addtional information: Index was outside the bounds of the array
location:
nbar = Me.ctSchedule1.AddTimeBar( nIndex, OleDtRdr.GetInt32(4), OleDtRdr.GetInt32(5), OleDtRdr.GetValue(3), OleDtRdr.GetValue(3))
Addtional information: Index was outside the bounds of the array
location:
nbar = Me.ctSchedule1.AddTimeBar(
do not replace the indices as you are doing here...
nbar = Me.ctSchedule1.AddTimeBar( nIndex, OleDtRdr.GetInt32(4), OleDtRdr.GetInt32(5), OleDtRdr.GetValue(3), OleDtRdr.GetValue(3))
you are just reading three fields from transaction table... TimeStart, TimeEnd, Date/ Use what I have shown..
nbar = Me.ctSchedule1.AddTimeBar( nIndex, OleDtRdr.GetInt32(0), OleDtRdr.GetInt32(1), OleDtRdr.GetValue(2), OleDtRdr.GetValue(2))
nbar = Me.ctSchedule1.AddTimeBar(
you are just reading three fields from transaction table... TimeStart, TimeEnd, Date/ Use what I have shown..
nbar = Me.ctSchedule1.AddTimeBar(
ASKER
sorry I think that might have been my fault..
I'm testing it again
I'm testing it again
see my SELECT statement...
SqlStr = "select TimeStart,TimeEnd,Date from tblTransactions where agent_id = " & strID
SqlStr = "select TimeStart,TimeEnd,Date from tblTransactions where agent_id = " & strID
ASKER
sorry I had been used to the table indices.. my fault.. well anyway.. it does work but it takes 1 to 2 min to pull just 1000 records..
ASKER
Thank you for all your help by the way.. I don't think I would have gotten this far with out your help...My last strand of hair thanks you too..
you are welcome... glad that I could help.. :))
ASKER
is there anyway to speed this up??
I would suggest, join the two tables in sql query and make it a single query. But, I guess here you can't do that , b/c you need... nIndex = Me.ctSchedule0.AddItem(str ID & ";" & strLname & ";" & StrFname)
and then you want to use that nIndex for nbar. I am not sure how to make it faster.
and then you want to use that nIndex for nbar. I am not sure how to make it faster.
ASKER
why does DAO load data so much faster?
DAO is no longer supported in VB.Net.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vxcondatacontrolchangesinvisualbasicnet.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbcondatachangesinvisualbasicnet.asp
-Baan