hi to everyone...i have this very simple problem that i cant fixed..
when i select an item in the dropdownlist to be a reference to query in the table it gives me an error: object reference not set to an instance of an object:
what's wrong w/ it???PHP Code:<style>
.verdana{
font:8pt verdana;
}
</style>
<%@ Page Language="vb" %>
<%@ import namespace="System.data" %>
<%@ import namespace="System.data.Sqlclient" %>
<html>
<head>
</head>
<script runat=server>
sub btnonclick(s as object,e as eventargs)
dim cn as new sqlconnection("initial catalog=northwind;integrated security=true;data source=localhost")
dim dt as new datatable("sample")
dim da as new Sqldataadapter("select * from region where regionid=" & category.selecteditem.text,cn)
da.fill(dt)
mygrid.datasource=dt
mygrid.databind()
end sub
</script>
<body>
<form runat=server>
<asp:button class=arial text="display table" onclick="btnonclick" runat="server"/>
<p>
<%dim cn as new sqlconnection("initial catalog=northwind;integrated security=true;data source=localhost")
cn.open()
dim cm as new sqlcommand("select * from region",cn)
dim dr as sqldatareader = cm.executereader()
while dr.read()
category.items.add(dr(0))
end while%>
<p>
<font face="verdana" size=2>Category:</font> <asp:dropdownlist class="verdana" id="category" runat=server/>
<p>
<asp:datagrid id="mygrid" class="verdana" backcolor="lightgray" headerstyle-backcolor="#ccccff" runat="server"/>
</form>
</body>
</html>
pls help..![]()
tanx in advance guys..


Reply With Quote
