Print Page | Close Window

asp arrays and database

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=20081
Printed Date: 29 March 2026 at 10:57pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: asp arrays and database
Posted By: dj air
Subject: asp arrays and database
Date Posted: 28 May 2006 at 5:34pm
does anyone know if there is a way you can save an array into a MSSQL database?






Replies:
Posted By: michael
Date Posted: 29 May 2006 at 4:04am
Not directly, no. There is no array datatype or function to this day for MSSQL. You can fairly simply convery an array to xml though and store it in a nvarchar field in 2000 or an xml field in 2005

-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: MadDog
Date Posted: 29 May 2006 at 5:53am
I have actually done research on trying to figure out how to store arrays in MSSQL... after searching for a few days i have not found any possible way to do it.

-------------
http://www.iportalx.net" rel="nofollow">


Posted By: dfrancis
Date Posted: 29 May 2006 at 5:04pm
I was going to post my thoughts on this the other day but was waiting for someone with experience. (grin)
 
Depending on the dimension and length, would it be possible to convert it to a string with your own deliminators? Then when you pull it out, convert it back to an array?
 
 
0 value,value
1 value,value
2 value,value
3 value,value
4 value,value
5 value,value
 
StrValue = value,value|value,value|value,value|value,value|value,value|value,value|
 
 
Just a thought. My other thought was to save it to a text file instead. I didn't go into research mode... sorry.


Posted By: dj air
Date Posted: 29 May 2006 at 8:56pm
yea my next idea was to store it as a string using deliminators,

it was making the array etc which is more Processing etc... and a text file isnt realistic as its a list of sub users for each user.. and is accessed when authenticating...

so i think i have to either 1. convert it to deliminators and use maths to work out the value(maths)

OR create a new table called sub users....... i didnt want to do that because it would mean 2 queries instead of one.

thanks all


Posted By: michael
Date Posted: 29 May 2006 at 9:38pm
The text file works but using a structured format e.g. xml gives you better performance. I found a failry straightforward example on gg which works fine and you can get the array back pretty much the same way.

<%@ Language=VBScript %>
<%
Option Explicit


Dim myarray(1,1)
Dim intCounter
Dim objXML
Dim objRootNode
Dim objNode
Dim objNodeValue


myarray(0,0) ="EmployeeID"
myarray(0,1)=123456
myarray(1,0)="FirstName"
myarray(1,1)="Saurabh"


Set objXML = CreateObject("MSXML2.DOMDocument")
Set objRootNode = objXML.createElement("rootTag")
Call objXML.appendChild(objRootNode)


For intCounter = 0 to UBound(myarray)
Set objNode = objXML.createElement(myArray(intCounter,0))
Set objNodeValue = objXML.createTextNode(myArray(intCounter,1))


Call objRootNode.appendChild(objNode)
Call objNode.appendChild(objNodeValue)
Next


Response.Write objXML.xml


%>


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: dj air
Date Posted: 29 May 2006 at 10:20pm
thanks thats helped, sort the issue

can create 2 functions one to create XML and one to create Array using XML data

... actually can use the XML to do the check without having to convert back to Array using the Nodes after loading the XML using Dom



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net