|
1. What is your query?
2. Attach the code you are using
|
|
|
|
|
Fayu wrote: 1. What is your query?
2. Attach the code you are using
Here is the code for the SqlDataSource:
<<asp:sqldatasource
id="sqlDataSourceG5WingRailCar"
="" runat="server" connectionstring="<%$ ConnectionStrings:oracleConnectionString %>" providername="<%$ ConnectionStrings:oracleConnectionString.ProviderName %>" selectcommand="select distinct to_date( mh.historydatetime , 'DD-MM-YYYY' ) ,
rh.movedescription ,
( mds.pct_util * count( rh.movedescription ) )
from requesthistory rh
inner join movehistory mh on rh.itd_number = mh.itd_number
inner join movedescription mds on rh.movedescr_id = mds.movedescr_id
where rh.movedescr_id = 1 AND mh.discrepancy_id = 25 AND EXTRACT(MONTH FROM mh.historydatetime) = :MONTH_ID
group by to_date( mh.historydatetime , 'DD-MM-YYYY' ) ,
rh.movedescription ,
mds.pct_util
order by to_date( mh.historydatetime , 'DD-MM-YYYY' )" onselecting="sqlDataSourceG5WingRailCar_Selecting">
<<selectparameters>>
<<asp:controlparameter
="" controlid="dropDownListMonth" name="MONTH_ID" propertyname="SelectedValue">>
<>
<>
<>
There really is no code for the Selecting Event, other than just capturing some text into a label when the event occurs (for testing purposes).
Thanks
|
|
|
|
|
Hi
I am currently working on converting a classic asp page to c# asp.net . I have come across this and was wondering if anyone would know the c# equivalent. It basically runs through a url string and takes the values out after every '=' sign. I was wondering if anyone could help.
function findField( fieldName, postResponse )
items = split( postResponse, chr( 13 ) )
for idx = LBound( items ) to UBound( items )
item = replace( items( idx ), chr( 10 ), "" )
if InStr( item, fieldName & "=" ) = 1 then
' found
findField = right( item, len( item ) - len( fieldName ) - 1 )
Exit For
end if
next
end function
Thanks
Dean
|
|
|
|
|
You would just use the Split('=') command on your string. For instance:
string[] replies = reply.Split('=');
|
|
|
|
|
Ouch. First let's clean up that VBScript code:
Function FindField(ByVal fieldName, postResponse)
fieldName = fieldName & "="
items = Split(postResponse, vbCrLf)
For idx = 0 to UBound(items)
If InStr(item, fieldName) = 1 Then
FindField = Mid(item, Len(fieldName) + 1)
Exit For
End If
Next
End Function
Now it's easy to translate:
public string FindField(string fieldName, string postResponse) {
fieldName += "=";
foreach (string item in Regex.Split(postResponse, "\r\n")) {
if (item.StartsWith(fieldName)) {
return item.SubString(fieldName.Length);
}
}
}
---
single minded; short sighted; long gone;
|
|
|
|
|
i have a grid view.now i have added a template field to it and placed a check box in it.now i want to edit the selected rows only on click of edit button which is placed below grid view.
i want to edit multiple rows of grid view whick are selected by a checkbox..can anyone send the code as soon as possible
|
|
|
|
|
sudheer babu kodavati wrote: can anyone send the code as soon as possible
Can you send us the cash as soon as possible.
on a serious note, atleast try a bit and someone here can always help you if you are stuck somewhere. Dont expect someone to give you the cooked rice.
|
|
|
|
|
Manas Bhardwaj wrote: Can you send us the cash as soon as possible.
Just get his mailing address and send him an invoice
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Can anyone tell me how to add header and footer to a dynamically generated word document using .net 2.0 ? I am able to generate the word document but i am unable to add/make visible the headers and footers in the document. I want page numbers to be coming up in the footers and some text in the header for all the pages in the doc... A quick response will be very much helpful....
Nithin Kumar V, .NET Developer
-- modified at 9:12 Saturday 21st July, 2007
I am using ASP.NET for this purpose.. This should be interesting... i havent got exact solution yet... any help is very helpful...
Nithin Kumar V, .NET Developer
|
|
|
|
|
is there any link that exports the data to excel from dataset using asp.net 2005 (vb.net)
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
|
Hello,
I really somebody's help, please,
I need to get the count of rows that are equal to the given string. but I don't know how to store the result. Here is the code:
SqlDataSource1.SelectCommand="SELECT count(paperID) FROM Papers WHERE (paperID="+paperID+")";
now I need to get the value of count(paperID) and give it to some variable, like this:
int selectedNum = SqlDataSource1.Select();
if (selectedNum == 0)<br />
try<br />
{<br />
string insertID = "INSERT INTO Papers(paperID) VALUES (" + paperID + ");";<br />
SqlDataSource1.InsertCommand = insertID;<br />
SqlDataSource1.Insert();<br />
ok = true;<br />
}<br />
catch (Exception eee)<br />
{ ok = false; }
thank you!
|
|
|
|
|
hi,
first create a command object and then exectue the query i.e. select count(*) statement.
when executing the command object use the executescalar method and equate the result to an integer value.
the sample code:
sqlCommand cmd = new SqlCommand();
cmd.commandtype = commandtype.text
//assign your query to the command here
int count = cmd.executescalar()
....
carry on with your rest of the code, hope this helps.
Gautham
|
|
|
|
|
Thanx for your replay, but it shows me this error:
Error 1 Cannot implicitly convert type 'object' to 'int'. An explicit conversion exists (are you missing a cast?)
I changed it, but still I get this exception:
Exception Details: System.InvalidOperationException: <br />
ExecuteScalar: Connection property has not been initialized.<br />
<br />
Source Error:<br />
<br />
Line 52: cmd.CommandText="SELECT count(paperID) FROM Papers WHERE (paperID="+paperID+")";<br />
Line 53:
Line 54: int count=(int) cmd.ExecuteScalar();<br />
thanx
|
|
|
|
|
Let me know is paperID is ur parameter? If yes then when u r going to select then pass this parameter as well
int selectedNum = SqlDataSource1.select(paperID);
hope this will help u
Regards, Arslan Ilyas
|
|
|
|
|
Hi, the following code is taken from a tutorial on reading blobs by Ganegoda.
Private Sub CreateImage(ByVal id As String)<br />
<br />
Dim _con As New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("DB"))<br />
<br />
Try<br />
_con.Open()<br />
Dim _cmd As SqlCommand = _con.CreateCommand()<br />
_cmd.CommandText = "select logo from" + " pub_info where pub_id='" + id + "'"<br />
Dim _buf As Byte() = CByte(_cmd.ExecuteScalar())<br />
Response.ContentType = "image/gif"<br />
Response.BinaryWrite(_buf)<br />
Catch<br />
Finally<br />
_con.Close()<br />
End Try<br />
End Sub
I am new to vb.net and not very familiar with it. I have 2 questions regarding the code above.
1) Why is there a plus sign before and after id in the line where pub_id='" + id + "'" ?
2) From reading the MSDN, _con.CreateCommand() is supposed to create a connection and return a SqlCommand object associated with the current connection. However I'm still not clear as to what that means. Is it the same as the following?
<br />
Dim _cmd As SqlCommand <br />
Dim Filter as String<br />
Filter = "select logo from" + " pub_info where pub_id='" + id + "'"<br />
_cmd = New SqlCommand(Filter, _con) <br />
Thanks in advance for your help.
-- modified at 4:04 Sunday 15th July, 2007
|
|
|
|
|
ASPnoob wrote: 1) Why is there a plus sign before and after id in the line where pub_id='" + id + "'"?
The + operator is used for addition. When used on strings it means that the strings are concatenated.
ASPnoob wrote: 2) From reading the MSDN, _con.CreateCommand() is supposed to create a connection and return a SqlCommand object associated with the current connection. However I'm still not clear as to what that means.
This code:
Dim _cmd As SqlCommand = _con.CreateCommand()
is equivalent to:
Dim _cmd As New SqlCommand(Nothing, _con)
---
single minded; short sighted; long gone;
|
|
|
|
|
ASPnoob wrote: Filter = "select logo from" + " pub_info where pub_id='" + id + "'"
Have to be careful with this code. It is prone to SQL Injection attacks. Look at this article[^] on preventing SQL injection attacks.
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Hi Ganegoda,
The + sign is nothing but used for string concatenation. have u noticed that 'id' is we are passing with the string where pub_id=....., thats why we need to concatenate with plus signs on both sides.
Take care.
Please let me know if you have still doubts.........
Best Regards,
Mohammed Hameed.
Be a good professional who shares programming secrets with others.
|
|
|
|
|
Hi.I host one page,i done that page in C#[ASP.Net].i just add one Label and given Text as "Welcome" after hosting this page when i open this page the page is blank,when i take the source of the page am getting Label1.text=Welcome what is the problem.should i set any property.
|
|
|
|
|
Are you sure it is not invisible? :->
|
|
|
|
|
It sounds like you have put some code in the wrong place. The server code runs on the server and is not visible in the html source, so somehow you have put the code somewhere where it's not server code any more.
I can't tell you any more than that without seeing any code.
---
single minded; short sighted; long gone;
|
|
|
|
|
The Following code is SourceCode [ HTML Code ].In the HTML Code can see one Label Control and the Text is Welcome,even that also is not displaying after hosting this page.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Photos.aspx.cs" Inherits="Photos" EnableSessionState="False" %>
<title>Untitled Page
<asp:label id="Label1" runat="server" style="z-index: 100; left: 188px; position: absolute;
top: 46px" text="Welcome" width="237px" backcolor="#0066FF" forecolor="White">
<asp:datagrid id="dgPhotos" runat="server" style="z-index: 102; left: 168px; position: absolute;
top: 79px" cellspacing="20" gridlines="None" onitemcreated="dgPhotos_ItemCreated">
<columns>
<asp:templatecolumn>
<itemtemplate>
<itemstyle font-bold="False" font-italic="False" font-overline="False" font-strikeout="False"
="" font-underline="False" horizontalalign="Center" verticalalign="Middle">
|
The Page Load Event as follows
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable("Photos");
dt.Columns.Add("Photos", Type.GetType("System.String"));
foreach (string Files in Directory.GetFiles(Request.MapPath("Photos"), "*.jpg"))
{
dt.Rows.Add(Files);
}
ds.Tables.Add(dt);
this.dgPhotos.DataSource = ds;
this.dgPhotos.DataBind();
}
}
|
|
|
|
|
Half of you code is missing or unreadable. Use the "Ignore HTML" option when you are posting markup code.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi Guffa,
i am using the following code to export dataset data to excel in asp.net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Not Page.IsPostBack) Then
Dim con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\Administrator\Desktop\a.mdb")
con.Open()
Dim ds As New Data.DataSet
Dim ad As New OleDbDataAdapter("select * from a", con)
ad.Fill(ds)
GridView1.DataSource = ds
GridView1.DataBind()
End If
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
'// If you want the option to open the Excel file without saving then
'// comment out the line below
'// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls"
Dim stringWrite As System.IO.StringWriter = New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView1.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()
End Sub
there is occuring an error
Control 'GridView1' of type 'GridView' must be placed inside a form tag with runat=server.
but the control is under the form tag with runat server
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|