Talk:Team:TU-Delft/SynBioData
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
+ | |||
<html> | <html> | ||
- | < | + | <head> |
- | + | <title>Read from Excel or Access</title> | |
- | + | <script language="JavaScript"> | |
- | + | function getCount() | |
- | + | { | |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
- | + | var s = fso.CreateTextFile("C:\\ASPConnection\\test.txt", true); | |
- | + | var t = fso.CreateTextFile("C:\\ASPConnection\\test1.txt", true); | |
- | + | var r = fso.CreateTextFile("C:\\ASPConnection\\test2.txt", true); | |
- | + | var cn = new ActiveXObject("ADODB.Connection"); | |
- | + | var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:\\ASPConnection\\Barcodes_VOCS_2011.xls;Persist Security Info=False;Extended Properties=Excel 8.0;"; | |
+ | cn.Open(strConn); | ||
+ | var rs = new ActiveXObject("ADODB.Recordset"); | ||
+ | var SQL = "select * from [Sheet7$]"; | ||
+ | rs.Open(SQL, cn); | ||
+ | if(rs.bof) | ||
+ | { | ||
+ | document.write('No records available for this query'); | ||
+ | } | ||
+ | if(!rs.bof) | ||
+ | { | ||
+ | rs.MoveFirst() | ||
+ | while(!rs.eof) | ||
+ | { | ||
+ | var store = rs.fields(2).value; | ||
+ | for(var i=0; i!= rs.fields.count; ++i) | ||
+ | { | ||
+ | document.write(rs.fields(i).value + ","); | ||
+ | t.Write(rs.fields(i).value + ","); } | ||
+ | s.WriteLine(rs.fields(2).value + ","); | ||
+ | t.WriteLine(","); | ||
+ | document.write("<br />"); | ||
+ | rs.MoveNext() } | ||
+ | } | ||
+ | rs.Close(); | ||
+ | cn.Close(); | ||
+ | s.Close(); | ||
+ | t.Close(); | ||
+ | r.Close(); | ||
} | } | ||
- | + | var ForReading = 1, ForWriting = 2, ForAppending = 8; | |
+ | var TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0; | ||
+ | var fso = new ActiveXObject("Scripting.FileSystemObject"); | ||
- | + | // Open the files for input and output | |
- | + | //CHANGE THESE LOCATIONS TO ENSURE THAT : | |
- | + | // a) testfile1.txt exists and | |
- | + | // b) testfile2.txt can be created and is writable | |
- | + | var filename1 = "C:\\ASPConnection\\test.txt"; | |
+ | var filename2 = "C:\\ASPConnection\\test2.txt"; | ||
- | </ | + | var f1 = fso.OpenTextFile(filename1, ForReading, true); |
+ | // Open the file for input. | ||
+ | f2 = fso.OpenTextFile(filename2, ForWriting); | ||
+ | |||
+ | var r = f1.ReadLine(); //This line will read the data to the input file | ||
+ | var g = r; | ||
+ | // Read from the file and display the results. | ||
+ | var r = f1.ReadLine(); //This line will read the data to the input file | ||
+ | f2.WriteLine(r); //This line will write the data to the output file | ||
+ | document.write(r + "<br />"); | ||
+ | // Read from the file and display the results. | ||
+ | while (!f1.AtEndOfStream) | ||
+ | { | ||
+ | if(r!=g) | ||
+ | {var r = f1.ReadLine(); //This line will read the data to the input file | ||
+ | document.write (r + "<br />"); //This line will display the data on the screen | ||
+ | f2.WriteLine(r); //This line will write the data to the output file | ||
+ | var g = r; | ||
+ | } | ||
+ | else | ||
+ | {var r = f1.ReadLine(); //This line will read the data to the input file | ||
+ | } | ||
+ | /*var r = f1.ReadLine(); //This line will read the data to the input file | ||
+ | document.write (r + "<br />"); //This line will display the data on the screen | ||
+ | f2.WriteLine(r); //This line will write the data to the output file*/ | ||
+ | } | ||
+ | f1.Close(); | ||
+ | f2.Close(); | ||
+ | </script> | ||
+ | </head> | ||
+ | <body> | ||
+ | <input type="button" value="Get count" onClick="getCount()"> | ||
</body> | </body> | ||
</html> | </html> | ||
+ | |||
+ | Reply With Quote |
Revision as of 09:45, 2 September 2013
Reply With Quote