emin3m
10-04-2005, 04:55 PM
i feel like a n00b right now
ne ways
i am a php developer
but client needs the project in asp.net (VB)
there are several things am stuck with
i cant finnd session_id(); in it
session_id(); in php generates some unique session id
every example on web i see mentioning
Session("someVariable")="youDesiredValue"
but i need auto generated unique value instead of "youDesiredValue"
secondly
i am getting data form mysql.....
i can write data on the page but cant use the data :(
check the code for viewing products
"preety stupid code "
<%@ Page Language="VB" AutoEventWireup="False"
EnableSessionState="true" EnableViewState="False" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>
<% '''''''''''''''''''Sesssion
'''''''''''''''''''''''''''Session End
%>
<%
Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=eshop;uid=root;option=3"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim cmd As OdbcCommand = New OdbcCommand("select * from products where category_id=0" & Request.QueryString("cat"), con)
con.Open()
dgrAllNames.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
dgrAllNames.DataBind()
con.Close()
con.Open()
cmd= New OdbcCommand("select * from categories", con)
dgrAllNames2.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
dgrAllNames2.DataBind()
%>
<html>
<head>
<title>Displaying Records from MySQL 'Names' table</title>
<style>
body { font: 100% Verdana; }
</style>
</head>
<body>
header here
<p align="center">All records in the 'Names' table:</p>
<form runat="server">
<asp:DataList ID="dgrAllNames2" HorizontalAlign="Center"
CellPadding="3" Runat="server" >
<ItemTemplate>
<a href="products.aspx?cat=<%#Container.DataItem("category_id")%>"><%#Container.DataItem("name")%></a>
</ItemTemplate>
</asp:DataList>
<asp:DataList ID="dgrAllNames" HorizontalAlign="Center"
CellPadding="3" Runat="server" >
<ItemTemplate>
<a href="cart.aspx?prodid=<%#Container.DataItem("pid")%>">
<%#Container.DataItem("name")%>
<%#Container.DataItem("description")%>
<%#Container.DataItem("category_id")%>
<%#Container.DataItem("price")%>
<%#Container.DataItem("quantity")%>
<%#Container.DataItem("manf_id")%>
<%#Container.DataItem("picture")%>
</a>
</ItemTemplate>
</asp:DataList>
</form>
footer here
</body>
</html>
how can i do that if there are no rows in the result of products then display "No Products in this category"
let me know ASAP
ne ways
i am a php developer
but client needs the project in asp.net (VB)
there are several things am stuck with
i cant finnd session_id(); in it
session_id(); in php generates some unique session id
every example on web i see mentioning
Session("someVariable")="youDesiredValue"
but i need auto generated unique value instead of "youDesiredValue"
secondly
i am getting data form mysql.....
i can write data on the page but cant use the data :(
check the code for viewing products
"preety stupid code "
<%@ Page Language="VB" AutoEventWireup="False"
EnableSessionState="true" EnableViewState="False" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>
<% '''''''''''''''''''Sesssion
'''''''''''''''''''''''''''Session End
%>
<%
Dim ConnStr As String = "Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=eshop;uid=root;option=3"
Dim con As OdbcConnection = New OdbcConnection(ConnStr)
Dim cmd As OdbcCommand = New OdbcCommand("select * from products where category_id=0" & Request.QueryString("cat"), con)
con.Open()
dgrAllNames.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
dgrAllNames.DataBind()
con.Close()
con.Open()
cmd= New OdbcCommand("select * from categories", con)
dgrAllNames2.DataSource = cmd.ExecuteReader(CommandBehavior.CloseConnection Or CommandBehavior.SingleResult)
dgrAllNames2.DataBind()
%>
<html>
<head>
<title>Displaying Records from MySQL 'Names' table</title>
<style>
body { font: 100% Verdana; }
</style>
</head>
<body>
header here
<p align="center">All records in the 'Names' table:</p>
<form runat="server">
<asp:DataList ID="dgrAllNames2" HorizontalAlign="Center"
CellPadding="3" Runat="server" >
<ItemTemplate>
<a href="products.aspx?cat=<%#Container.DataItem("category_id")%>"><%#Container.DataItem("name")%></a>
</ItemTemplate>
</asp:DataList>
<asp:DataList ID="dgrAllNames" HorizontalAlign="Center"
CellPadding="3" Runat="server" >
<ItemTemplate>
<a href="cart.aspx?prodid=<%#Container.DataItem("pid")%>">
<%#Container.DataItem("name")%>
<%#Container.DataItem("description")%>
<%#Container.DataItem("category_id")%>
<%#Container.DataItem("price")%>
<%#Container.DataItem("quantity")%>
<%#Container.DataItem("manf_id")%>
<%#Container.DataItem("picture")%>
</a>
</ItemTemplate>
</asp:DataList>
</form>
footer here
</body>
</html>
how can i do that if there are no rows in the result of products then display "No Products in this category"
let me know ASAP