hi..
i've this 2D array of size a[15,15] which i want to store into MS Access 2003 for further processing on the matrix n future use.
Since there is no built in data type in Access as 'array' or 'matrix' or '2D array'....can anyone help!!!
Thanking you all in advance...
waiting for a fast response....
11 2844
hi..
i've this 2D array of size a[15,15] which i want to store into MS Access 2003 for further processing on the matrix n future use.
Since there is no built in data type in Access as 'array' or 'matrix' or '2D array'....can anyone help!!!
Thanking you all in advance...
waiting for a fast response....
You could easily populate a Table with the data contained in the 2 Dimensional Array in order to 'Persist' the data. It would then be a relatively simple matter to use the GetRows() Method which will return a 2 Dimensional Array from a Recordset based on the Table. This would be your retrieval Method. BTW, what is the Data Type of the Array Elements and what does it represent? a(15, 15) would current hold 256 members since Arrays are indexed at 0, is this your intention?
You could easily populate a Table with the data contained in the 2 Dimensional Array in order to 'Persist' the data. It would then be a relatively simple matter to use the GetRows() Method which will return a 2 Dimensional Array from a Recordset based on the Table. This would be your retrieval Method. BTW, what is the Data Type of the Array Elements and what does it represent? a(15, 15) would current hold 256 members since Arrays are indexed at 0, is this your intention?
I didn't get ur reply...yes, ur rite i've a 15 x 15 2D array consisting of byte values...i.e 256 byte values.
See i've this array on visual studio 2005, doing my pogramming on images in C#,. What i've done till now is to extract the pixel values of a 15x15 window. Now the next thing i want to do is to store that array in MS Access so that i can work on them and apply other functions on them.
So my main problem is to store the matrix into MS Access, I've esablished the connection...so can u elaborate how an i store the values...rite from scratch. It will be very helpful of you....and after storing how do i access the array elements ....
Thanking you...
I didn't get ur reply...yes, ur rite i've a 15 x 15 2D array consisting of byte values...i.e 256 byte values.
See i've this array on visual studio 2005, doing my pogramming on images in C#,. What i've done till now is to extract the pixel values of a 15x15 window. Now the next thing i want to do is to store that array in MS Access so that i can work on them and apply other functions on them.
So my main problem is to store the matrix into MS Access, I've esablished the connection...so can u elaborate how an i store the values...rite from scratch. It will be very helpful of you....and after storing how do i access the array elements ....
Thanking you...
I'll see what I can come up with, but please be patient since I am very busy at the moment.
thanks..and yep..being patient...reply soon!!
thanks..and yep..being patient...reply soon!!
You seem to be in a 'great hurry', so I'll post what I have so far, and I'm sure the rest you can handle. Download my Test Database, and customize it to suit your specific needs. It is fully functional in its current state. -
'In General Declarations Section of Form's Code Module
-
Option Compare Database
-
Option Explicit
-
Private aBytePixelPos(15, 15) As Byte
-
- To Save sample 2-Dimensional Bytye Array data to a Table:
-
'Private aBytePixelPos(15, 15) As Byte declared in Form Module
-
Dim intCounter_1 As Integer
-
Dim intCounter_2 As Integer, MyDB As DAO.Database, rstPixelVals As DAO.Recordset
-
-
Set MyDB = CurrentDb()
-
Set rstPixelVals = MyDB.OpenRecordset("tblPixelValues", dbOpenDynaset)
-
-
'Delete any previous Records in tblPixelValues
-
CurrentDb.Execute "Delete * From tblPixelValues", dbFailOnError
-
-
Randomize 'Seed the Random Number Generator
-
-
'Fill the 2-Dimensional Array (Matrix) with 256 Byte values
-
For intCounter_1 = LBound(aBytePixelPos) To UBound(aBytePixelPos)
-
For intCounter_2 = LBound(aBytePixelPos) To UBound(aBytePixelPos)
-
aBytePixelPos(intCounter_1, intCounter_2) = Int(Rnd() * 256)
-
Next intCounter_2
-
Next intCounter_1
-
-
'Now that the Array is populated, let's add the Values to tblPixelValues in
-
'Row1..Col1,,Col2..Col3..Col4 fashion up to Column16, then new Row..Repeat
-
For intCounter_1 = LBound(aBytePixelPos) To UBound(aBytePixelPos) 'Rows
-
rstPixelVals.AddNew
-
For intCounter_2 = LBound(aBytePixelPos) To UBound(aBytePixelPos) 'Columns
-
Select Case intCounter_2 'Populate the appropriate Column
-
Case 0
-
rstPixelVals![Field1] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 1
-
rstPixelVals![Field2] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 2
-
rstPixelVals![Field3] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 3
-
rstPixelVals![Field4] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 4
-
rstPixelVals![Field5] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 5
-
rstPixelVals![Field6] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 6
-
rstPixelVals![Field7] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 7
-
rstPixelVals![Field8] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 8
-
rstPixelVals![Field9] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 9
-
rstPixelVals![Field10] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 10
-
rstPixelVals![Field11] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 11
-
rstPixelVals![Field12] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 12
-
rstPixelVals![Field13] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 13
-
rstPixelVals![Field14] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 14
-
rstPixelVals![Field15] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case 15
-
rstPixelVals![Field16] = aBytePixelPos(intCounter_1, intCounter_2)
-
Case Else
-
End Select
-
Next intCounter_2
-
rstPixelVals.Update
-
Next intCounter_1
-
-
rstPixelVals.Close
-
Set rstPixelVals = Nothing
-
-
'See the results
-
DoCmd.OpenTable "tblPixelValues", acViewNormal, acReadOnly
-
DoCmd.Maximize
-
- To retrieve Table Data into a 2-Dimensional Array (Variant):
-
Dim MyDB As DAO.Database, rstPixelVals As DAO.Recordset
-
Dim aVarPixelVals As Variant, intRecord As Integer
-
'Dim aByteRetrieveArray(15, 15) As Byte
-
-
-
Set MyDB = CurrentDb()
-
Set rstPixelVals = MyDB.OpenRecordset("tblPixelValues", dbOpenDynaset)
-
-
-
'aVarPixelVals (a Variant Array) now holds all 256 Table Values
-
aVarPixelVals = rstPixelVals.GetRows(DCount("*", "tblPixelValues"))
-
-
'To retrieve all 256 Values in aVarPixelVals, The first subscript identifies
-
'the Field (0 to 15),and the second identifies the Row number (intRecord).
-
For intRecord = 0 To UBound(aVarPixelVals, 2) 'Row Counters
-
Debug.Print aVarPixelVals(0, intRecord) & ", " & aVarPixelVals(1, intRecord) & ", " & _
-
aVarPixelVals(2, intRecord) & ", " & aVarPixelVals(3, intRecord) & ", " & _
-
aVarPixelVals(4, intRecord) & ", " & aVarPixelVals(5, intRecord) & ", " & _
-
aVarPixelVals(6, intRecord) & ", " & aVarPixelVals(7, intRecord) & ", " & _
-
aVarPixelVals(8, intRecord) & ", " & aVarPixelVals(9, intRecord) & ", " & _
-
aVarPixelVals(10, intRecord) & ", " & aVarPixelVals(11, intRecord) & ", " & _
-
aVarPixelVals(12, intRecord) & ", " & aVarPixelVals(13, intRecord) & ", " & _
-
aVarPixelVals(14, intRecord) & ", " & aVarPixelVals(15, intRecord)
-
Next intRecord
-
-
'P.S. - If you're not happy storing the values in a Variant, Sub-Type Array, you cal always populate
-
'aconventional 2-Dimensional Array, but why the extra work unless it is absolutely required?
Thanks a TONNE for the reply....yeah, u guessed it right..."gr8 hurry"..hehe..well, i shall try with the database u attached with ur prev post. I'm wondering if there's any easier way to store a matrix of 256 values(15x15) in any other form( like XML,or any other persistant data storage technique) which will be easier than Accsss?
Can i store the whole 256 values into an Excel sheet and store that Excel Sheet into Access as an OLE object. But in that case i'm stuck on how to enter the values from Visual Studio 2005 to Excel. And then to retrieve the info back to Visual Studio!!!
Please help...!!!
Thanking you in advance!!
I went through the VBA code that u provided and tried to work out but as am completely alien to VBA( i know VB and C#) i cudn't understand all wht u've wrote.
The necessary steps i need t do is like:
1) Establish the connection between Visual Studio c#.NET and MS Access( which i've done)
2) Create a table in Access with 256 cells( which i've done)
3) Then populate the array in Visual Studio (which i've done) 4) Then insert the values of my array into the table in Access( help!!!)
5) Then once inserted, retrieve the values back to Visual Studio.(help!!)
Thanks for the help...
I went through the VBA code that u provided and tried to work out but as am completely alien to VBA( i know VB and C#) i cudn't understand all wht u've wrote.
The necessary steps i need t do is like:
1) Establish the connection between Visual Studio c#.NET and MS Access( which i've done)
2) Create a table in Access with 256 cells( which i've done)
3) Then populate the array in Visual Studio (which i've done) 4) Then insert the values of my array into the table in Access( help!!!)
5) Then once inserted, retrieve the values back to Visual Studio.(help!!)
Thanks for the help...
as am completely alien to VBA ( i know VB and C#)
If you know VB, you cannot be completely alien to VBA.
Then once inserted, retrieve the values back to Visual Studio
The retrieval logic is already contained within the Test Database.
You already have the 2-Dimensional Array populated in Step #3. To Insert the values into a Table, simply substitute your Array Name for aBytePixelPos in the code below, assuming the same Table name and Field alignment: -
'Private aBytePixelPos(15, 15) As Byte declared in Form Module
-
Dim intCounter_1 As Integer
-
Dim intCounter_2 As Integer, MyDB As DAO.Database, rstPixelVals As DAO.Recordset
-
-
Set MyDB = CurrentDb()
-
Set rstPixelVals = MyDB.OpenRecordset("tblPixelValues", dbOpenDynaset)
-
-
'Delete any previous Records in tblPixelValues
-
CurrentDb.Execute "Delete * From tblPixelValues", dbFailOnError
-
-
Randomize 'Seed the Random Number Generator
-
-
'Fill the 2-Dimensional Array (Matrix) with 256 Byte values
-
For intCounter_1 = LBound(aBytePixelPos) To UBound(aBytePixelPos)
-
For intCounter_2 = LBound(aBytePixelPos) To UBound(aBytePixelPos)
-
aBytePixelPos(intCounter_1, intCounter_2) = Int(Rnd() * 255)
-
Next intCounter_2
-
Next intCounter_1
-
-
'Now that the Array is populated, let's add the Values to tblPixelValues in
-
'Row1..Col1,,Col2..Col3..Col4 fashion up to Column16, then new Row..Repeat
-
For intCounter_1 = LBound(aBytePixelPos) To UBound(aBytePixelPos) 'Rows
-
rstPixelVals.AddNew
-
For intCounter_2 = LBound(aBytePixelPos) To UBound(aBytePixelPos) 'Columns
-
rstPixelVals.Fields(intCounter_2) = aBytePixelPos(intCounter_1, intCounter_2)
-
Next intCounter_2
-
rstPixelVals.Update
-
Next intCounter_1
-
-
rstPixelVals.Close
-
Set rstPixelVals = Nothing
-
-
'See the results
-
DoCmd.OpenTable "tblPixelValues", acViewNormal, acReadOnly
-
DoCmd.Maximize
NeoPa 32,556
Expert Mod 16PB
I went through the VBA code that u provided and tried to work out but as am completely alien to VBA( i know VB and C#) i cudn't understand all wht u've wrote.
The necessary steps i need t do is like:
1) Establish the connection between Visual Studio c#.NET and MS Access( which i've done)
2) Create a table in Access with 256 cells( which i've done)
3) Then populate the array in Visual Studio (which i've done) 4) Then insert the values of my array into the table in Access( help!!!)
5) Then once inserted, retrieve the values back to Visual Studio.(help!!)
Thanks for the help...
DeathFrag,
You seem to be having problems with this which are beyond the scope of an Access forum thread. ADezii has gone to great lengths to help you to implement the Access side of this problem, but your attempts to incorporate that into your overall solution is really outside of our remit.
It seems that you haven't quite grasped what ADezii was trying to explain (about 16 values in 16 records for instance). There is really little more that he can do for you (beyond the hours of work he's already put in for you).
Admin.
I wud like to thank ADezii for ur effort in solving my problem...thanks a lot..yeah ur rite i cant be complete alien to VBA..i fugured out wht u did in that code. I loved it....although i was looking for something simpler and required lesser code.
And while going through ur code, something strikd me...wht i did was very simple and wud like to share with you guys: c#.net code snippet: -
try
-
{
-
-
String Query;
-
OleDbConnection myconn = new OleDbConnection(@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\Documents and Settings\tonmoy\Desktop\db1.mdb");
-
OleDbDataReader myreader;
-
OleDbCommand mycommand;
-
-
-
myconn.Open();
-
byte test;
-
int K = 1;
-
for (int i = 0; i < 12; i++)
-
{
-
-
Query = "insert into table1 values(" + a[i, 0] + "," + a[i, 1] + "," + a[i, 2] + "," + a[i, 3] + "," + a[i, 4] + "," + a[i, 5] + "," + a[i, 6] + "," + a[i, 7] + "," + a[i, 8] + "," + a[i, 9] + "," + a[i, 10] + "," + a[i, 11] + " )";
-
mycommand = new OleDbCommand(Query, myconn);
-
myreader = mycommand.ExecuteReader();
-
myreader.Close();
-
-
}
-
myconn.Close();
-
}
-
catch(OleDbException e1)
-
{
-
-
MessageBox.Show(e1.Errors[0].Message);
-
-
}
-
-
The only thing i did( which ironically was very simple n how foolish of me...i asked tht in this forum)..was to create a connection, initilise a dataReader and a datacommand, insert the query into a string and execute it...as i did above..and while storing the values..store them in matrix fashion...with just one loop....man this was simple....
Sorry for givingu guys some pain....but i appreciate ur solution and time tht u spent on solvng my problem..Thanks a lot..
Looking forward to further assistance in future...
Bye..
DeathFrag..
NeoPa 32,556
Expert Mod 16PB
Thanks for posting your work here, and recognising ADezii's efforts.
Good luck in the rest of your project and Welcome to TheScripts :)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben Ingram |
last post by:
Hi all,
I am writing a template matrix class in which the template parameters are
the number of rows and number of columns. There are a number of reasons
why this is an appropriate tradeoff for...
|
by: Charulatha Kalluri |
last post by:
Hi,
I'm implementing a Matrix class, as part of a project. This is the interface
I've designed:
class Matrix( )
|
by: manning_news |
last post by:
Has anyone had a problem with Access 2003 not saving their coding?
I've been using 2003 for a couple of months now and just this week
noticed that some coding I'd done for a database was not there...
|
by: raj |
last post by:
Hi,
I saw it mentioned that "int" is the fastest data-type for use in C
,that is data storage/retrieval would be the fastest if I use int among
the following 4 situations in a 32 bit machine with...
|
by: Kim Bracknell |
last post by:
Hi there,
In v 0.6 of Web Matrix, if I add a new database connection using the wizard
and choose "Access Database" I get the following error:
"Unable to create project. The Microsoft Access...
|
by: Doug |
last post by:
Hi
I have been working through Scott Mitchell's book on asp.net in 24 hours and
found the book very informative - within the web matrix API.
However when I try to move those new skills into...
|
by: tt40 |
last post by:
Anyone know how to prevent Access 2002 from automatically breaking all
the incorrect joins in a query and then automatically saving the broken
query?
This is what I would call stupid design...
|
by: MVM |
last post by:
I am new to VS 2003. I did programming in vb6 and vc6, but not through
studio. I am having lot of confusion on how to start, where to start?
I like to write a program in vc++ under vs 2003. i...
|
by: =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= |
last post by:
Hello,
I´m using a very large 2-dimensional double matrix (45.000x45.000)
in my program.
At the initialization of the matrix:
double matrix = new double I am getting an out of memory...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |