Click here to Skip to main content
13,594,513 members
Rate this:
Please Sign up or sign in to vote.
Hi all,
I want to know whether is it possible to get data from a ms access database and store the values into an array created inside a script so that i can use the values for form validation. If possible, please guide me how.

Thanks in advance
Posted 16-Oct-12 20:23pm
Updated 16-Oct-12 20:24pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Linq is the answer. You can convert a DataTable to IEnumerable using the AsEnumerable method. Then, the ToArray() converts it to an array.

//1. Fetch data from the access and store it in DataTableName.

// 2. convert datatable into array.
var tableEnumerable = DataTableName.AsEnumerable();
tableArray = tableEnumerable.ToArray(); 

// 3.1 srealize your code for JS, create seperate function for this. do this in your .ASPX.CS page

 protected string GetTabValue() 
    {         // you can do more processing here         ....         ....         // use serializer class which provides serialization and deserialization functionality for AJAX-enabled applications.  
        JavaScriptSerializer jSerializer=new JavaScriptSerializer(); 
        // serialize your object and return a serialized string   
      return jSerializer.Serialize(tableArray );

//3.2 Acces this function in your js and do what you want to do . this should be in you .aspx page.
var x = '<%=GetTabValue()%>';
  // called server side method
Sriram Mani 17-Oct-12 2:44am
thanks sinhasourabh,
would you mind explain me a little briefly, because im new to c# and
sinhasourabh 17-Oct-12 2:53am
I assumed that you are using .net 3.5 or above framework.
What we need to do is
1. fetch data from your database using oledb and store it in a datatable. (pls google this, if you dont know how to do it.)
2. convert you table table into array.
3. access your array from JS.

please find relative code in above answer, i have updated the code with points.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2


I think it is better if you can google this simple question you can find number of ways

Try this link^
Sriram Mani 17-Oct-12 2:45am
thanks adi,
Ill go through these links.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.180621.3 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2018
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100