At any rate, for troubleshooting/development, I'd like to have some
kind of flexibility/portability -- the original developer hardcoded
and created dependencies on a lot of stuff. What I'd like to do for
right now is add data to the datagrid without being connected to the
database (where the datasource gets it's records):
Here is the existing code:
Sub Window_OnLoad()
Set oTable = document.all.item("myTable")
ADC.CursorLocation = adUseClient
sSel = "select ORDER_NUMBER, ORDER_DESC from ORDER_DATA where
primary_flag = 1 order by ORDER_NUMBER asc "
ADC.Open sSel, window.parent.MyCon, adOpenKeyset, adLockOptimistic
Set oTable.DataSource = ADC
End Sub
What if I'm not connected to or have access to the database? The
datagrid doesn't have any rows... Is there anyway I can manually add
data to the recordset? Or do I even have to use a recordset? Is
there another object which can be the datasource?
Thanks!
How useful is the app without a connection to the DB?
It is possible purely with code to create an instance of an ADODB recordset,
build a set fields and then populate it with records. However is ADC a
recordset?
Looks like a VB6 or VBA question to me. There may be a better place for you
to ask this question.
--
Anthony Jones - MVP ASP/ASP.NET
Thanks for the reply...
> How useful is the app without a connection to the DB?
pretty darn useless... but I'd like as I posted originally, I'm trying
to do some mx on the page and I'd like to explore some options without
having to get data; I'd like to make my own test data and use that...
and doing it all from the client side is certainly convenient for my
prototyping. It will be hooked back up to the DB later.
> Looks like a VB6 or VBA question to me. There may be a better place for you
> to ask this question.
I'll try there but this is all client side code and there are no ASP
tags in the page... all the script I posted is nested between a plain
<script language="vbscript"> tag
There is such a thing as a disconnected recordset. I don't know where you
get your data from, but if you can hard code some records, this may help. A
brief example:
============
Const adVarChar = 200
Const adSmallInt = 2
Const adDBTimeStamp = 135
Const MaxCharacters = 255
' Setup disconnected recordset.
Set objDataList = CreateObject("ADODB.Recordset")
objDataList.Fields.Append "Description", adVarChar, MaxCharacters
objDataList.Fields.Append "Number", adSmallInt
objDataList.Fields.Append "Date", adDBTimeStamp, MaxCharacters
objDataList.Open
' Create a few records.
objDataList.AddNew
objDataList("Description") = "Start"
objDataList("Number") = 4
objDataList("Date") = #8/16/2007#
objDataList.Update
objDataList.AddNew
objDataList("Description") = "Middle"
objDataList("Number") = 2
objDataList("Date") = #8/17/2007#
objDataList.Update
objDataList.AddNew
objDataList("Description") = "End"
objDataList("Number") = 3
objDataList("Date") = #8/18/2007#
objDataList.Update
objDataList.Sort = "Number"
' Display sorted values.
objDataList.MoveFirst
Do Until objDataList.EOF
Wcript.Echo objDataList.Fields.Item("Description") _
& "," & objDataList.Fields.Item("Number") _
& "," & objDataList.Fields.Item("Date")
objDataList.MoveNext
Loop
objDataList.Close
--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--
Richard.... thanks a million. In spite of my possibly poor-worded
original post, this is exactly what I wanted. I was previously
unfamiliar with the term (or concept of) disconnected recordset.
Thanks again!