:: Forum >>

Please Find a Bug in my program

Hi,

I have created a program in asp.net with ActiveWidgets. Every thing is working fine, Grid is displaying but problem is that my Data is not displaying in the GRID. instead of Data program is showing me Blank Row.

Please help me, here is my code it's too big but please help me.

<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>

<Script Runat="Server">

Dim S As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\example.mdb"
Dim Conn as OledbConnection
Dim Cmd as OledbCommand
Dim Reader1 as OledbDataReader

Sub Page_Load( s1 As Object, e As EventArgs )
Conn = new oledbconnection(S)
Dim Sql, Str As String
Sql = "select * from table1"
Conn.Open()
Cmd = New OleDbCommand(Sql, Conn)
Reader1 = Cmd.ExecuteReader()
end sub

Sub Page_unload()
Reader1.Close()
Conn.Close()
End Sub

Private Function aw_string(ByVal s2 as String)AS String
s2 = s2.Replace("\", "\\")
s2 = s2.Replace("""", "\""") 'replace javascript control characters - ", \
rem s2 = s2.Replace(vbCr, "\r")
rem s2= s2.Replace(vbLf, "\n")

Return """" & s2 & """"
End Function


Function aw_headers(ByVal Reader1 as Oledb.OledbDataReader)AS String
Dim i, count, headers()
count = Reader1.FieldCount
ReDim headers(count-1)
For i=0 to count-1
headers(i) = aw_string(Reader1.GetName(i))
Next
Response.Write("["& Join(headers,",")& "];")
Return ""
end function


Function aw_cells(ByVal Reader1 as OledbDataReader)AS String
Dim i,col_count, row_count, columns(), rows()
row_count = 0
ReDim columns(col_count-1)
While(Reader1.Read())
For i = 0 To col_count - 1
columns(i) = aw_string(Reader1(i).ToString())
Next
ReDim preserve rows(row_count)
rows(row_count) = vbTab & "[" & Join(columns, ", ") & "]"
row_count = row_count + 1
End While

Response.Write("["& vbNewLine & Join(rows,","& vbNewLine)& vbNewLine & "];" & vbNewLine)
Return ""
end function

</Script>

<html>
<head>
<script src="ActiveWidgets/runtime/lib/aw.js"></script>
<link href="ActiveWidgets/runtime/styles/xp/aw.css" rel="stylesheet"></link>
</head>
<body>
<script>

// insert javascript arrays produced by ASP.NET functions
var myHeaders = <%= aw_headers(Reader1) %>
var myCells = <%= aw_cells(Reader1) %>
// create grid control
var obj = new AW.UI.Grid;

// set grid text
obj.setHeaderText(myHeaders);
obj.setCellText(myCells);

// set number of columns/rows
obj.setColumnCount(myHeaders.length);
obj.setRowCount(myCells.length);

// write grid to the page
document.write(obj);

</script>
</body>
</html>
Harshit
Thursday, August 10, 2006
Thanx Guys

I found error, i forgot the

col_count = Reader1.FieldCount

in aw_cells function now it's working fine

Harshit.
Harshit
Thursday, August 10, 2006
Evry thing is working fine no bug at all not at all
SAm
Friday, December 22, 2006

This topic is archived.


Back to support forum

Forum search