:: Forum >>
how to save the data on access with asp
Hi Please help!
As you see below the data is coming from access and dispalyed on an editable grid. How can is save this data back to the table?
<%@ LANGUAGE = VBScript %>
<%
Dim oConnection
Dim oRecordset
' connect to the database
Set oConnection = Server.CreateObject("ADODB.Connection")
oConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("courses.mdb")
' retrieve the grid data
Set oRecordset = oConnection.Execute("SELECT * FROM tblStudents")
' encodes control characters for javascript
function aw_string(s)
s = Replace(s, "\", "\\")
s = Replace(s, """", "\""") 'replace javascript control characters - ", \
s = Replace(s, vbCr, "\r")
s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
' returns the field names from the recordset formatted as javascript array
function aw_headers(oRecordset)
Dim i, count, headers()
count = oRecordset.fields.count
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(oRecordset(i).name)
Next
Response.write("[" & Join(headers, ", ") & "];")
end function
' returns the recordset data formatted as javascript array
function aw_cells(oRecordset)
Dim i, col_count, row_count, columns(), rows()
row_count = 0
col_count = oRecordset.fields.count
ReDim columns(col_count-1)
Do while (Not oRecordset.eof)
For i=0 to col_count-1
columns(i) = aw_string(oRecordset(i))
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
oRecordset.MoveNext
Loop
Response.write("[" & vbNewLine & Join(rows, "," & vbNewLine) & vbNewLine & "];" & vbNewLine)
end function
%>
<html>
<head>
<title>ActiveWidgets Examples</title>
<style>body {font: 12px Tahoma}</style>
<!-- include links to the script and stylesheet files -->
<script src="runtime/lib/aw.js"></script>
<link href="runtime/styles/xp/aw.css" rel="stylesheet" />
<!-- change default styles, set control size and position -->
<style>
#myGrid {height: 150px}
</style>
</head>
<body>
<h3>ASP classic - VBScript, ADO</h3>
<p>Make VBScript functions returning the data formatted as javascript arrays,<br />
Insert the results inside Javascript data block</p>
<!-- insert control tag -->
<span id="myGrid"></span>
<!-- add data block -->
<script>
// insert javascript arrays produced by ASP functions
var myHeaders = <%= aw_headers(oRecordset) %>
var myCells = <%= aw_cells(oRecordset) %>
</script>
<!-- create and configure the grid control -->
<script>
// create grid control
var grid = new AW.UI.Grid;
// assign the grid id (same as placeholder tag above)
grid.setId("myGrid");
// set grid text
grid.setHeaderText(myHeaders);
grid.setCellText(myCells);
//grid.setCellText(true);
grid.setCellEditable(true);
// set number of columns/rows
grid.setColumnCount(myHeaders.length);
grid.setRowCount(myCells.length);
// write grid to the page
grid.refresh();
var Testbutton=new AW.UI.Button;
Testbutton.setControlText("Submit");
document.write(Testbutton);
Testbutton.onClick=function(){}
</script>
</body>
</html>
<%
oRecordset.close
oConnection.close
%>
br
Saturday, November 10, 2007
I do not believe that nobody so far has implemented something like this.
Hey Asp or Asp.net users how do you guys store the data back to databases whether is access or sql database? Please provide some kind of example.
The boss would be very happy to know that this is done and propably will buy the package.
Any comments?
b
Monday, November 12, 2007
Nobody help that? (:(
tonle
Wednesday, February 13, 2008
hi there
can you explain me the working of this given code.what does it means.
encodes control characters for javascript
function aw_string(s)
s = Replace(s, "\", "\\")
s = Replace(s, """", "\""") 'replace javascript control characters - ", \
s = Replace(s, vbCr, "\r")
s = Replace(s, vbLf, "\n")
aw_string = """" & s & """"
end function
why to encode control characters for js.what is the need of this code.
Thank you
www.intelcs.com
jitesh
Thursday, February 21, 2008
Hi, dudes,
I'm Shahyn
Can you please help me to make a form in html that store data to exel file
shaheen
Friday, February 22, 2008
This topic is archived.
Back to support forum
Forum search