|
Hi,
This is my situation, I have a ASP.NET website that has a mysql database behind it.
I can't work out how to store news articles.
Basically my news articles are written in MS word and saved as web pages, then changed to .txt files to give me the html code that will display the text the same as it is diplayed in the original word file.
But I can't store this html string in my mysql database using a gridview insert command to insert it. It doesn't like special characters. The mysql field type is text.
At the moment I am getting around it by just storing the .txt file name in the database, then finding it, and using StreamReader to read the html code. This works fine, but it means every news article has to be stored as a .txt file in the server file. I won't to be able to save this data in the database.
I don't won't to open a new page to display the news article.
Am I going about this the wrong way, is there a better way to store news articles?
Is there a way to insert the special characters into the mysql database using gridview?
|
|
|
|
|
hello all....,
i have a error, but it's can working.. i have post this in forum 4 thread and codeproject 3 thread, but they give answer can not working... so, pls... help...
i have 2 page like default.aspx and cart.aspx.
this is my code:
default.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<title>Untitled Page
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:GAMESConnectionString %>"
="" selectcommand="SELECT * FROM [items]">
<asp:repeater id="Repeater1" runat="server" datasourceid="SqlDataSource1">
<headertemplate>
<itemtemplate>
<asp:label id="kode" runat="server" text="<%#Eval("Kode") %>">
<asp:label id="name" runat="server" text="<%#Eval("Name") %>">
<asp:label id="cost" runat="server" text="<%#Eval("cost","{0:n}") %>">
<asp:textbox id="total" text="1" runat="server" width="24px">
<asp:button id="addtocart" runat="server" commandname="buy" text="add to cart" postbackurl="~/cart.aspx?from=default">
<footertemplate>
default.aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Private kode As String = ""
Private name As String = ""
Private total As Integer = 0
Private cost As Double = 0
Public Function dataList() As ArrayList
Dim itemselecting As ArrayList = New ArrayList
itemselecting.Add(kode)
itemselecting.Add(name)
itemselecting.Add(total)
itemselecting.Add(cost)
dataList = itemselecting
End Function
Protected Sub Repeater1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles Repeater1.ItemCommand
kode = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("kode"), Label).Text
name = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("name"), Label).Text
total = CInt(CType(Repeater1.Items(e.Item.ItemIndex).FindControl("total"), TextBox).Text)
cost = CType(Repeater1.Items(e.Item.ItemIndex).FindControl("cost"), Label).Text
End Sub
End Class
cart.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="cart.aspx.vb" Inherits="cart" %>
<title>Untitled Page
<asp:repeater id="Repeater1" runat="server">
<itemtemplate>
kode | name | total | cost | subtotal | <asp:label id="label1" runat="server" text="<%#DataBinder.eval(Container.DataItem,"Kode") %>"> | <asp:label id="label2" runat="server" text="<%#DataBinder.eval(Container.DataItem,"Name") %>"> | <asp:textbox id="txttotal" runat="server" text="<%#DataBinder.eval(Container.DataItem,"total") %>"
="" width="20px"> | <asp:label id="label3" runat="server" text="<%#DataBinder.eval(Container.DataItem,"cost") %>"> | <asp:label id="label4" runat="server" text="<%#DataBinder.eval(Container.DataItem,"subTotal") %>"> | grand total: | <asp:label id="total" runat="server" text="0"> | | <asp:label id="subtotal" runat="server" text="0"> |
|
<asp:button id="Button1" runat="server" text="update">
cart.aspx.vb
Partial Class cart
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not PreviousPage Is Nothing AndAlso PreviousPage.IsCrossPagePostBack Then
Dim itembuy As Integer
Dim itemselecting As ArrayList = New ArrayList
If (Request.QueryString("from") = "default") Then
itemselecting = CType(Me.PreviousPage, _default).datalist()
End If
itembuy = Session("Itembuy")
If Not checksameitem(itemselecting(0)) Then
Session("Kode_" & itembuy) = itemselecting(0)
Session("Name_" & itembuy) = itemselecting(1)
Session("total_" & itembuy) = itemselecting(2)
Session("cost_" & itembuy) = itemselecting(3)
Session("subtotal_" & itembuy) = itemselecting(2) * itemselecting(3)
itembuy += 1
Session("itembuy") = itembuy
End If
displayData()
End If
If Not IsPostBack Then
Me.displayData()
End If
End Sub
Private Sub displayData()
Dim a As ArrayList = New ArrayList()
Dim itembuy As Integer
Dim i As Integer
Dim totalItem As Integer = 0
Dim totalcost As Double = 0
itembuy = Session("itembuy")
For i = 0 To itembuy - 1
a.Add(New DataKasir(Session("Kode_" & i), Session("Name_" & i), Session("total_" & i), Session("cost_" & i), Session("subtotal_" & i)))
totalItem += Session("total_" & i)
totalcost += Session("subTotal_" & i)
Next
Me.total.Text = totalItem
Me.subtotal.Text = Format(totalcost, "#,##0.00")
Repeater1.DataSource = a
Repeater1.DataBind()
End Sub
Private Function checksameitem(ByVal kode As String) As Boolean
Dim totalItem As Integer = Session("itembuy")
Dim i As Integer
For i = 0 To totalItem
If (Session("Kode_" & i) = kode) Then
checksameitem = True
End If
Next
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim totItem As Integer = Repeater1.Items.Count
Dim total As Integer
Dim cost As Double
Dim i As Integer
For i = 0 To totItem - 1
total = IIf(CType(Repeater1.Items(i).FindControl("txttotal"), TextBox).Text = "", 0, _
CType(Repeater1.Items(i).FindControl("txttotal"), TextBox).Text)
cost = CDbl(Session("cost_" & i))
Session("total_" & i) = total
Session("subtotal_" & i) = total * cost
Next
displayData()
End Sub
End Class
Public Class DataKasir
Private myKode As String
Private myName As String
Private mytotal As Integer
Private mycost As Double
Private mysubtotal As Double
Public Sub New(ByVal nKode As String, ByVal nName As String, ByVal ntotal As Integer, ByVal ncost As Double, ByVal nsubTotal As Double)
Me.myKode = nKode
Me.myName = nName
Me.mytotal = ntotal
Me.mycost = ncost
Me.mysubtotal = nsubTotal
End Sub
Public ReadOnly Property Kode() As String
Get
Return myKode
End Get
End Property
Public ReadOnly Property Name() As String
Get
Return myName
End Get
End Property
Public ReadOnly Property total() As Integer
Get
Return mytotal
End Get
End Property
Public ReadOnly Property cost() As Double
Get
Return mycost
End Get
End Property
Public ReadOnly Property subTotal() As Double
Get
Return mysubtotal
End Get
End Property
End Class
my error is in the cart.aspx.vb like the command:
If (Request.QueryString("from") = "default") Then
itemselecting = CType(Me.PreviousPage, _default).datalist()
the error is" type _default is not defined" .. i have no idea to solve this... it can work properly.. but this error can active if there is a some error or warning in the page.
if page not have any errors or warning, this error can not active,but sometimes can error..
so i want to this error resolved, i want _default can be defined...
plz... helppp.....
thx......
|
|
|
|
|
hardyyanto wrote: i have a error
can you explain the error and show the code that is specific to the error?
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
yes.., in the cart.aspx.vb:
itemPilihan = CType(Me.PreviousPage,_default).datalist()
my errors is _default ("type _default is not defined").
i want to take class _default from default.aspx.vb. but the cart.aspx.vb can not detect the class _default.
if i debug program, it can detect, but sometimes can not detect, so, i rebuild website, it can detect, but sometimes not again, so i rebuild again..again..
that datalist is not type, but is name of function in default.aspx.vb.
pls, copy default.aspx,default.aspx.vb, cart.aspx,cart.aspx.vb to your computer.
and try it..my table is only one like items(kode(varchar),name(varchar),cost(money)).
many member that answer my question are not try my data, they only reading that page, then answer it, so it can not work...
pls...thx...
|
|
|
|
|
Hi,
The code below works in one of my xp pro machine and fails to compile in another machine with same os. I'm referring excel 11.0 in my application and i have installed Excel 2003(11.8146.8132) SP2 in my machine.
Can any one help with this.
string strSavePath = Server.MapPath(".") + "\\";
strSavePath += "Emb.xls";
// Application ExcelApp = null;
//_Workbook ExcelWorkbook = null;
//_Worksheet ExcelWorkSheet = null;
Excel.Application ExcelApp = null;
Excel.Workbook ExcelWorkbook = null;
Excel.Worksheet ExcelWorkSheet = null;
if (ExcelWorkSheet != null)
ExcelWorkSheet = null;
if (ExcelWorkbook != null)
ExcelWorkbook = null;
if (ExcelApp != null)
ExcelApp.Quit();
//ExcelApp = new Application();
//ExcelWorkbook = (_Workbook)(ExcelApp.Workbooks.Add(Type.Missing));
//ExcelWorkSheet = (_Worksheet)ExcelWorkbook.Sheets["Sheet1"];
ExcelApp = new Excel.Application();
ExcelWorkbook = (Excel.Workbook)(ExcelApp.Workbooks.Add(Type.Missing));
ExcelWorkSheet = (Excel.Worksheet)ExcelWorkbook.Sheets["Sheet1"];
ExcelWorkSheet.get_Range("A3", "E41").EntireColumn.AutoFit();
ExcelApp.Visible = true;
ExcelApp.DisplayFullScreen = false;
What should i do to make it work in all the machines.
Kindly help me.
Thanks and Regards,
PLS
|
|
|
|
|
helo all...,
i have create procedure can decrease totalcost from order table(database:games.dbo) with balance in bill table(database:bank.dbo). my 2 database in same server is name "boy"
i have 2 database like: bank.dbo and games.dbo
in games.dbo, have a table name is order(user_id,no_order,date,totalcost)
in bank.dbo, have a table name like is bill(no_bill,balance)
this is a list of bill table
no_bill balance
111222 200$
222444 10$
this is a list of order table
user_id no_order date totalcost
a 1 1/1/07 50$
when customer insert no_bill(111222) in page and click a button, then bill table became
no_bill balance
111222 150$
222444 10$
when customer insert no_bill(222444) in page and click a button, then message "sorry, your balance is not enough"
mystore procedure like:
ALTER PROCEDURE [dbo].[pay]
(
@no_bill AS INT,
@no_order AS int,
@totalcost AS money
)
AS
BEGIN
BEGIN TRANSACTION
DECLARE @balanc AS money
SET @balanc= (SELECT [balance] FROM Bank.dbo.bill WHERE [no_bill] = @no_bill)
UPDATE [bank.dbo.bill]
SET
[balance] = @balanc - @totalcost
WHERE
[no_bill] = @no_bill
COMMIT TRANSACTION
END
it can decrease money in bank, but i want it ceck money if balance > totalcost, so balance-totalcost,
if balance<totalcost,so error="" message"sorry,="" your="" balance="" is="" not="" enough"
when="" i="" execute="" store="" procedure="" pay,="" insert="" no_bill,no_order,totalcost.
i="" want="" if="" totalcost="" that=""> balance, it display message"sorry, your balance is not enough"
is it can make in procedure?
thx...
|
|
|
|
|
Include a IF condition in the procedure that checks whether the Acc.Balance is greater than the TotalCost. If yes Update the Balance and Commit transaction else Raise error and rollback transaction.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
thx for ur responding..
my store procedure like that:
ALTER PROCEDURE [bank].[dbo].[pay]
(
@no_bill INT,
@no_order int,
@totalcost money,
@message varchar(100) -- make it output parameter in your stored procedure
)
AS
BEGIN TRANSACTION
DECLARE @balance AS money
select @balance = balance
from bank.dbo.bill
where no_bill = @no_bill
select @totalcost = totalcost
from games.dbo.totalcost
where no_order = @no_order
if (@balance > @totalcost)
begin
set @balance = @balance - @totalcost
UPDATE bank.dbo.bill
SET
[balance] = @balance
WHERE [no_bill] = @no_bill
-- set @message = 'your have enough balance'
end
else
begin
set @message = 'sorry, your balance not enough'
end
COMMIT TRANSACTION
set nocount off
but it's not display message. it's must use output code to display it. but i don't about output code. can u add output code to my store procedure?pls...
thx
|
|
|
|
|
By using DataRelation , we can able to fetch the matched records of two datatables.
How can i get the unmatched records of the two datatables in code behind?
Note : Note in MS-SQL Query.
For example
Datatable 1
----------------
Id
---
100
101
102
103
104
Datatable 2
----------------
Id
----
100
102
My Expecting result is
Id
----
101
103
104
|
|
|
|
|
why dont u use filters
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
Navigate thorugh the DataTable records and Build a resultant DataTable with the records based on the condition.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
|
This is ASP.NET discussion board...
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Please - no cross posting.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi, I have a html image in one page like this
GetInfo() is javascript function.
How i can get image's Location in javascript function? (Compatible with Firefox)
thanks.
|
|
|
|
|
I found my solution :
function GetInfo(img)
{
SRC=img.src
HEIGHT=img.offsetHeight;
WIDTH=img.offsetWidth;
TopLocation=img.offsetTop;
LeftLocation=img.offsetLeft;
}
|
|
|
|
|
Hello Everybody
I'm sending the mail i'm receiving blank text or nothing or sometimes i got error ...................
I'm putting my code here plz have a look and suggest me the problem exists in my code
I've already taken following controls.......given below
hidden Field= txtID
IFRAME = manojTextBox
-----------------------------------------------------------
Page_Load
if(!Page.IsPostBack)
{
cmdClick.Attributes.Add("onClick","document.Form1.txtID.value=manojTextBox.document.body.innerHTML");
}
-----------------------------------------------------------
Click Event
MailMessage mail1=new MailMessage();
mail1.To="mail@saamstesting.com";
mail1.From="manoj.manojbisht@gmail.com";
mail1.Subject="This is New Mail -2";
mail1.Priority=MailPriority.High;
mail1.BodyFormat=MailFormat.Html;
mail1.Body=Request.Form["txtID"];
try
{
SmtpMail.SmtpServer="mail.saamstesting.com";
SmtpMail.Send(mail1);
lblMsg.Text="Mail Sent Successfully";
lblMsg.ForeColor=Color.DarkBlue;
}
catch(Exception ex)
{
lblMsg.Text=ex.Message.ToString();
lblMsg.ForeColor=Color.Red;
}
|
|
|
|
|
The Knowledge wrote: cmdClick.Attributes.Add("onClick","document.Form1.txtID.value=manojTextBox.document.body.innerHTML");
try something like this instead
var iFrame= document.getElementById("IFrame1");<br />
document.getElementById("txtID").value = iFrame.document.innerHTML;
and have a look at the below link
How to send SMTP mail in ASP.NET using C# technology[^]
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Hello
I am a beginner and I really need hlp
The problem is that :-
I want to display the Button id of the button which has been clicked on a new page on being clicked and the text also i mean buton.text.
Mrinal
|
|
|
|
|
Do you mean that you want to pass the button ID and TEXT to the new page on the click of a Button? If yes...
On the button click event use Reponse.Redirect to call the new page. Along wi the page URL you can pass the button ID and TEXT as query string values.
something like this...
Response.Redirect("NewPage.aspx?btnId=" + btn.ID + "&btntext=" + btn.Text, False)
and In the New page you can retrieve the values using Request object.
Request.QueryString("btnId")<br />
Request.QueryString("btntext")
the above statement will give you the vaues that you passed from the actual page.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
Thanks..
I have 4 buttons on my page .It worked for the first button but didn't work for the rest others ..
Mrinal
|
|
|
|
|
can we define the table and div property in the skin file in asp.net
please help me.
Piyush Vardhan Singh
Senior Software Engineer
TAS NewDelhi
India
|
|
|
|
|
Piyush Vardhan Singh wrote: can we define the table and div property in the skin file in asp.net
Skins: Allow you to define individual HTML Elements and Web control styles.
Regards J O H N
"Even eagles need a push." David McNally
|
|
|
|
|
thanks for reply.
First time i have using skin file.i want to use many ui for single page. please if u have any example or link then please give me.
thanks
Piyush Vardhan Singh
Senior Software Engineer
TAS NewDelhi
India
|
|
|
|
|
|