[Mono-list] Databind to SQLServer
John BouAntoun
jbouantoun@rogen.com.au
Fri, 16 May 2003 14:13:24 +1000
Larry,=20
May be there is a problem with the DataBinder.Eval method?
why not try using using a non-reflection based method call to render =
that table value (so you can debug it)?
This approach is actually faster (during runtime) and will enable you to =
debug the issue.
something like :
in the aspx file
<ItemTemplate>
<%#
RenderLName(Container.DataItem, "au_lname")=20
%>
</ItemTemplate>
and then in the pages code behind have a=20
protected string RenderLName(object dataView, string fieldName)
{
DataRowView dgi =3D dataView as DataRowView;
if (dgi=3D=3Dnull) return "";
string returnValue =3D dgi.Row[fieldName].ToString();
// maybe do some Console.WriteLines in here to debug the dataRowView
return returnValue;
}
Anyway, hope that helps you diagnose the issue better.
JBA (aka SecretSquirrel)
-----Original Message-----
From: Jones, Larry [mailto:LJones@Lithonia.com]
Sent: Friday, 16 May 2003 1:27 PM
To: 'mono-list@lists.ximian.com'
Subject: [Mono-list] Databind to SQLServer
I still have problems databinding to SQLServer. Since I last posted =
this
problem I upgraded to RedHat 9.0 and Mono 0.24. Still doesn't work. =
Exact
same program works fine On MS .Net but not on mono. Heres the code:
<%@ Import Namespace=3D"System.Data.SqlClient" %>
<%@ Page Language=3D"C#" %>
<script runat=3D"server">
public void Page_Load()
{
SqlDataReader reader;
string connectionString =3D "Server=3DSERVER;Database=3Dpubs;User
ID=3Dsa;Password=3Dpassword";
SqlConnection dbcon;
dbcon =3D new SqlConnection(connectionString);
dbcon.Open();
SqlCommand dbcmd =3D dbcon.CreateCommand();
string sql =3D=20
"SELECT au_fname, au_lname " +
"FROM Authors";
dbcmd.CommandText =3D sql;
reader =3D dbcmd.ExecuteReader();
dgAuthors.DataSource =3D reader;
dgAuthors.DataBind();
reader.Close();
dbcon.Close();
}
</script>
<Html>
<Body>
<H2>Testing Sql</H2>
<form runat=3D"server">
<asp:DataList ID=3D"dgAuthors" runat=3D"Server">
<ItemTemplate>
<%#
DataBinder.Eval(Container.DataItem, "au_lname") %>
</ItemTemplate>
</asp:DataList>
</form>
</Body>
</Html>
Any suggestions as to what is wrong would be appreciated.
Larry Jones
Hydrel/Lithonia Lighting
_______________________________________________
Mono-list maillist - Mono-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list