R
RAB
I am opening a simple database and filling a DataGrid:
The code is as follows:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
dim Conn as new OleDbConnection("Provider=" & _
"Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\inetpub\wwwroot\MyDataBase.mdb")
sub GetData(Sender as Object, e as EventArgs)
dim objCmd as OleDbCommand = new OleDbCommand _
("select * from LoginTable where UserID = @ID", Conn)
dim objReader as OleDbDataReader
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@ID", _
OleDbType.Integer)
objParam.Direction = ParameterDirection.Input
objParam.Value = tbID.Text
try
objCmd.Connection.open()
objReader = objCmd.ExecuteReader
catch ex as OleDbException
Label1.Text = "Error retrieving from the database."
end try
DataGrid1.DataSource = objReader
DataGrid1.DataBind()
objReader.Close
objCmd.Connection.Close()
end sub
</script>
<html><body>
<form runat="server">
<asp:Label id= "Label1" runat="server" /><br>
Enter an ID <asp:Textbox id= "tbID" runat="server"
AutopostBack=True
OnTextChanged=GetData /><p>
<asp
ataGrid id="DataGrid1" runat="server"
bordercolor="black" GridLines="Vertical"
cellpadding="4" cellspacing="0" width="100%"
Font-Name="Arial" Font-Size="8pt"
HeaderStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-BackColor="#cccccc"
AutoGenerateColumns="true" />
</form>
</body></html>
My problem is when I put the "1" into the textbox and press enter, the
datagrid does not
present itself. The page just shows the text and textbox. I have
tested the database and got it to populate a datalist correctly
earlier.
Any help would be appreciated.
Thanks,
RABMissouri
The code is as follows:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script language="VB" runat="server">
dim Conn as new OleDbConnection("Provider=" & _
"Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\inetpub\wwwroot\MyDataBase.mdb")
sub GetData(Sender as Object, e as EventArgs)
dim objCmd as OleDbCommand = new OleDbCommand _
("select * from LoginTable where UserID = @ID", Conn)
dim objReader as OleDbDataReader
dim objParam as OleDbParameter
objParam = objCmd.Parameters.Add("@ID", _
OleDbType.Integer)
objParam.Direction = ParameterDirection.Input
objParam.Value = tbID.Text
try
objCmd.Connection.open()
objReader = objCmd.ExecuteReader
catch ex as OleDbException
Label1.Text = "Error retrieving from the database."
end try
DataGrid1.DataSource = objReader
DataGrid1.DataBind()
objReader.Close
objCmd.Connection.Close()
end sub
</script>
<html><body>
<form runat="server">
<asp:Label id= "Label1" runat="server" /><br>
Enter an ID <asp:Textbox id= "tbID" runat="server"
AutopostBack=True
OnTextChanged=GetData /><p>
<asp
bordercolor="black" GridLines="Vertical"
cellpadding="4" cellspacing="0" width="100%"
Font-Name="Arial" Font-Size="8pt"
HeaderStyle-BackColor="#cccc99"
ItemStyle-BackColor="#ffffff"
AlternatingItemStyle-BackColor="#cccccc"
AutoGenerateColumns="true" />
</form>
</body></html>
My problem is when I put the "1" into the textbox and press enter, the
datagrid does not
present itself. The page just shows the text and textbox. I have
tested the database and got it to populate a datalist correctly
earlier.
Any help would be appreciated.
Thanks,
RABMissouri