Showing posts with label alli. Show all posts
Showing posts with label alli. Show all posts

Wednesday, March 21, 2012

please help me for this problem, as I havent done it before.

Hi, all

I want help for the below mentioned problems. PLease give example with source code. Please help me.


1. I have made upto this point. Now i want the functionality that when i enter the item orderd and discount the amount column should be updated as per the
following formula.
amount = rate*item orderd - discount

2. As the amount column updated the sub total should be changed.

3. as the user enter the taxes the grand total should also be changed.

Regards

sp_412000@dotnet.itags.org.yahoo.com



<%@dotnet.itags.org. Import Namespace="System.Data" %>
<%@dotnet.itags.org. Import Namespace="System.Data.OleDb" %>
<script runat="server" language="C#">
void Page_Load(Object src,EventArgs e)
{
OleDbConnection dbConn =
new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=/studynet/Authors2k.mdb;User Id=admin;Password=;" );
OleDbDataAdapter dbAdap = new OleDbDataAdapter("SELECT item_id,item_name,unit,rate,stock FROM product",dbConn);
DataSet ds = new DataSet();
dbAdap.Fill(ds,"product");
rept.DataSource = ds.Tables["product"].DefaultView;
rept.DataBind();
}
</script>
<html>
<form id="form1" runat="server">
<asp:repeater id="rept" runat="server">
<HeaderTemplate>
<table>
<tr>
<th>Del</th>
<th>Item #</th>
<th>Name</th>
<th>Unit</th>
<th>Rate</th>
<th>Item Ordered</th>
<th>Discount</th>
<th>Amount</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:CheckBox id="chk1" runat="server" />
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"item_id") %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem,"item_name") %>
</td>
<td>
<#% DataBinder.Eval(Container.DataItem,"unit") %>
</td>
<td>
<#% DataBinder.Eval(Container.DataItem,"rate") %>
</td>
<td>
<asp:textbox id="txt1" runat="server" />
</td>
<td>
<asp:textbox id="txt2" runat="server" />
</td>
<td>
<asp:textbox id="txt3" runat="server" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:repeater>
sub total: <asp:textbox id="subtot" runat="server" />
Taxes: <asp:textbox id="taxes" runat="server" />
Grand Total: <asp:textbox id="gtot" runat="server" />
</form>
</html>


the easiest way would be to add a button that performs the math functions when clicked
If you want it to be "automatic" then you would add a onchange eventfor the textboxes and have them do the approproate math when the textchanges
HTH

Please help me improve this class for accessing database data

Hi All

I've just written my first class that attempts to perform the following actions:
1. Connect to SQL Server 2000 using the connection defined in web.config
2. Execute a stored procedure (passed as a parameter) using any number of SQL parameters
3. Return the data as a dataTable back to the calling page

I need some really general advice from you experts to help improve it in the following ways if possible:
1. Reliability
2. Performance

Although it does work, it's probably quite badly written as to be honest I don't really know what I'm doing. Any help would be really appreciated! Big Smile [:D]

Namespace myNS
Public Class dataGrabber

Private Shared myConn As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnString").ConnectionString)
Private Shared mySQLCommand As New SqlCommand
Private Shared myDataReader As SqlDataReader

Public Sub New(ByVal storedProcedureToRun As String)
mySQLCommand.Connection = myConn
mySQLCommand.CommandText = storedProcedureToRun
mySQLCommand.CommandType = CommandType.StoredProcedure
End Sub

Public Sub AddParam(ByVal paramName As String, ByVal paramDataType As SqlDbType, ByVal paramValue As String)
Dim tmpParam As New SqlParameter(paramName, paramDataType)
tmpParam.Value = paramValue
mySQLCommand.Parameters.Add(tmpParam)
End Sub

Public ReadOnly Property getData() As DataTable
Get
Dim myDataTable As New DataTable
mySQLCommand.Connection.Open()
myDataReader = mySQLCommand.ExecuteReader(CommandBehavior.CloseConnection)
myDataTable.Load(myDataReader)
mySQLCommand.Parameters.Clear()
mySQLCommand.Dispose()
Return myDataTable
End Get
End Property

End Class
End Namespace

With my expereince, I always make my data layers static, there is really no need to maintain class instances in the data layer, however there are exceptions depending on the requirements of your project.

In my data layers, I execute a command like so: MyDataLayer.ExecuteDataSet(cn, "SP_NAME", object[] args);

notice the last parameter is an object array that will hold the parameters for the stored proc.

If you want some good ideas and good practices, download microsofts data access application block and look through the code. They have some good code in there that uses caching for parameters and connections, which speeds up the datalayer.

Also take a look at patterns & practices on msdn. there is alot of good info on there.


You shouldn't make your class-level variables (myConn etc) shared. And if you want to return a DataTable you could use the DataAdapter rather than getting a Reader and loading it into a DataTable.
Thanks both for your help.

>> You shouldn't make your class-level variables (myConn etc) shared
I thought Shared just meant that other subs and functions in the class could access these once they had been declared. Obviously not. What is Shared therefore?

>> if you want to return a DataTable you could use the DataAdapter rather than getting a Reader and loading it into a DataTable
Could you please provide an example of this that would fit the code above?

Thanks again guys! Big Smile [:D]
Shared means there is only one instance of the object that spans all classes. So if you create two instances of your data class they both share the same connection and command object. So if one user on your site is running SPA and at the same time another user is running SPB you will get unexpected results.

For the DataAdapter;

http://authors.aspalliance.com/aspxtreme/sys/data/Common/DataAdapterClassFill.aspx


Hi Aidy
From the examples I can see online, all use a dataAdapter to fill adataTable or dataSet. Therefore (from my basic understandingWink [;)]) I'dstill require the temporary dataTable in the class to pass back to the calling page, right?? On top of this,wouldn't the dataAdapter use more resources than the dataReader?

I'm using the class in my pages as follows;

Dim DBAccess As New myNS.dataGrabber("sp_getlogin") ' instance of class
DBAccess.AddParam("username", SqlDbType.NVarChar, loginControl.UserName) ' add param username
DBAccess.AddParam("password", SqlDbType.NVarChar, loginControl.Password) ' add param password
Dim loginTable As DataTable = DBAccess.getData() ' returns values from database to use for this user

Friday, March 16, 2012

please help me!

hi to all;
i'm using asp.net 1.1, c#.net.visual studio 2003 to make my asp web applicat
ion
in my application, i want when i add a new topic a link or icon about this t
opic appear in another page .
example:
consider we have two page "add new message" and the "show all messages"
in add new message page:
i use two text boxes to set a name of the topic and to write a content in th
e second text box.and then click on save/insert button to save the the mess
age in the database.
what i want is : after saving the message--> a link about this message appea
r in the "show all mesage page". so the other user when go to "show all mess
age page" can view a link --> click on it then redirect to the page where i
s the content of the messag
e.
what i want is mostly like what i do now
[i wrote a message name "Subject" textbox--> then i write now the content o
f the message in "Message" texbox-->then i will click on post button --
> then a link of my message "please help me !" will appear in forums page --
--> so the other users of t
he site can go to the forums page,see my message,click on it to view the con
tent of the message]
please help me with code,i really need help to do this ideaOn Jun 5, 10:26 pm, Mero wrote:
> hi to all;
> i'm using asp.net 1.1, c#.net.visual studio 2003 to make my asp web appli
cation
> in my application, i want when i add a new topic a link or icon about this
topic appear in another page .
> example:
> consider we have two page "add new message" and the "show all messages"
> in add new message page:
> i use two text boxes to set a name of the topic and to write a content in
the second text box.and then click on save/insert button to save the the me
ssage in the database.
> what i want is : after saving the message--> a link about this message appear in t
he "show all mesage page". so the other user when go to "show all message page" can
view a link --> click on it then redirect to the page where is the content of the m
ess
age.
> what i want is mostly like what i do now
> [i wrote a message name "Subject" textbox--> then i write now the content of the
message in "Message" texbox-->then i will click on post button --> then a link
of my message "please help me !" will appear in forums page --> so the other users
of
the site can go to the forums page,see my message,click on it to view the content of the me
ssage]
> please help me with code,i really need help to do this idea
You need a DataGrid control
http://samples.gotdotnet.com/quicks...c_datagrid.aspx

please help me!

hi to all;
i'm using asp.net 1.1, c#.net.visual studio 2003 to make my asp web application
in my application, i want when i add a new topic a link or icon about this topic appear in another page .

example:

consider we have two page "add new message" and the "show all messages"
in add new message page:

i use two text boxes to set a name of the topic and to write a content in the second text box.and then click on save/insert button to save the the message in the database.

what i want is : after saving the message--a link about this message appear in the "show all mesage page". so the other user when go to "show all message page" can view a link --click on it then redirect to the page where is the content of the message.

what i want is mostly like what i do now
[i wrote a message name "Subject" textbox--then i write now the content of the message in "Message" texbox-->then i will click on post button --then a link of my message "please help me !" will appear in forums page --so the other users of the site can go to the forums page,see my message,click on it to view the content of the message]

please help me with code,i really need help to do this ideaOn Jun 5, 10:26 pm, Mero wrote:

Quote:

Originally Posted by

hi to all;
i'm using asp.net 1.1, c#.net.visual studio 2003 to make my asp web application
in my application, i want when i add a new topic a link or icon about this topic appear in another page .
>
example:
>
consider we have two page "add new message" and the "show all messages"
in add new message page:
>
i use two text boxes to set a name of the topic and to write a content in the second text box.and then click on save/insert button to save the the message in the database.
>
what i want is : after saving the message--a link about this message appear in the "show all mesage page". so the other user when go to "show all message page" can view a link --click on it then redirect to the page where is the content of the message.
>
what i want is mostly like what i do now
[i wrote a message name "Subject" textbox--then i write now the content of the message in "Message" texbox-->then i will click on post button --then a link of my message "please help me !" will appear in forums page --so the other users of the site can go to the forums page,see my message,click on it to view the content of the message]
>
please help me with code,i really need help to do this idea


You need a DataGrid control
http://samples.gotdotnet.com/quicks...c_datagrid.aspx

PLEASE HELP ME! Access to SQL-Server!?!

Hi to all!

I am new to asp and databases...I got a program, that uses an access database...now I want the program to write the information into a SQL-database...what must I do?

Or what is important to change on the code?

thx

juviFirst migrate the data from access to SQL Server using the tools provided by SQL. Second, you will need to change your connection string to use the SQL data provider (www.connectionstrings.com). Lastly, you will probably need to change some of your queries b/c access queries are slightly different from T-SQL queries.