|
Hmm basically I doing a layman work which is trying to convert my DAL (data access layer) functions to objectDataSource properties, the function I'm calling accepts one argument which sometimes can be null / 0 since its optional. Below is my function as well as the DAL that it calls
Public Function fill(Optional ByVal orderID As Integer = 0) As DataTable<br />
Dim cmd As SqlCommand<br />
cmd = New SqlCommand<br />
Dim da As SqlDataAdapter<br />
da = New SqlDataAdapter<br />
Dim dt As DataTable<br />
<br />
Try<br />
dt = New DataTable<br />
cmd.Connection = _SQLConnection<br />
cmd.CommandType = CommandType.StoredProcedure<br />
cmd.CommandText = "nw_spSelectOrders"<br />
cmd.Transaction = _SQLTransaction<br />
<br />
If Not orderID.Equals(0) Then<br />
<br />
cmd.Parameters.Add(New SqlParameter("@orderID", SqlDbType.Int))<br />
cmd.Parameters("@orderID").Direction = ParameterDirection.Input<br />
cmd.Parameters("@orderID").Value = orderID<br />
End If<br />
<br />
da.SelectCommand = cmd<br />
da.Fill(dt)<br />
<br />
If Not dt.Rows.Count > 0 Then<br />
Throw New Exception("no record")<br />
<br />
Else<br />
Return dt<br />
<br />
End If<br />
<br />
Catch ex As Exception<br />
Throw New Exception(ex.Message)<br />
<br />
Finally<br />
cmd.Dispose()<br />
da.Dispose()<br />
<br />
End Try<br />
<br />
End Function
SP for the function above:
0 - returns all data
SET ANSI_NULLS ON<br />
SET QUOTED_IDENTIFIER ON<br />
GO<br />
<br />
alter PROCEDURE nw_spSelectOrders <br />
(<br />
@orderID int = 0<br />
<br />
)<br />
as<br />
begin<br />
<br />
Select o.orderID, <br />
od.quantity, <br />
od.unitprice, <br />
od.unitprice <br />
from orders as o<br />
left outer join [order details] as od<br />
on o.orderid = od.orderid<br />
where case when @orderID = 0 then 'selected'<br />
else<br />
case when o.orderID = @orderID then 'selected'<br />
else 'not selected'<br />
end <br />
end= 'selected'<br />
end
Whats wrong with passing 0? when I explicitly place orderID number I get result but passing 0 nada..
Please advice
Thanks Guys
-- modified at 20:49 Tuesday 11th September, 2007
|
|
|
|
|
Uhh please advise what? The error is REALLY descriptive, and two people here have given you the answer.
I advise you learn .NET or something, if you can't even figure out what a paremeterless constructor is.
|
|
|
|
|
I don't mean to be harsh all of us do start from baby step, those two people has given helpful suggestions and you.. you simply throw snow ball and say I advise you learn .NET or something ... or something?? WAD!
Big help anyways
|
|
|
|
|
I am using RegisterStartupScript to run a javascript and display a modal web form from my code behind page. In vb.net the code is:
strScript = "<script> OpenWebPrompt('The party size and quantitative/qualitative answers require that this request be cancelled. Please speak to a client id for further guidance.','www.cnn.com','Reset','Abort','','');</script>"
Page.RegisterStartupScript("OpenWebPrompt", strScript) where OpenWebPrompt is a javascript in this page.
When the form is displayed all looks OK, but a button is clicked, another instance of the form is displayed and only then is the vbscript of the web form called. I am a new web programmer so i apologize if this is a simple question.
The javascript is:
function OpenWebPrompt(msg, hlink, btn1, btn2, btn3, btn4)
{
var sOptions;
sOptions = "center: Yes; dialogHeight: 550px; dialogWidth: 720px;";
var oArgs = new Object();
oArgs.msg = msg;
oArgs.hlink = hlink;
oArgs.btn1 = btn1;
oArgs.btn2 = btn2;
oArgs.btn3 = btn3;
oArgs.btn4 = btn4;
var url = "../convertedcontrols/webprompt.aspx?msg=" + msg + "&btn1=" + btn1 + "&btn2=" + btn2 + "&btn3=" + btn3 + "&btn4=" + btn4 + "&hlink=" + hlink;
var w = window.showModalDialog(url,"",sOptions);
var objVal = document.getElementById("<%=Me.UniqueID%>_txtPromptReturn");
objVal.text = w
//document.forms(0).submit();
// return w;
}
The webform is:
<%@ AutoEventWireup="false" Codebehind="WebPrompt.aspx.vb" Inherits="CSFB.WebPrompt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<script runat="server">
sub btnClick(sender as object, e as system.eventargs)
ctype(sender,button).Text = ctype(sender,button).id & " clicked"
end sub
</script>
<title>WebPrompt</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 56px; POSITION: absolute; TOP: 152px" runat="server"
OnClick="btnClick" Text="Button" Visible="False"></asp:Button>
<asp:Button id="Button4" style="Z-INDEX: 104; LEFT: 280px; POSITION: absolute; TOP: 152px" runat="server"
OnClick="btnClick" Text="Button" Visible="False"></asp:Button>
<asp:Button id="Button3" style="Z-INDEX: 103; LEFT: 200px; POSITION: absolute; TOP: 152px" runat="server"
OnClick="btnClick" Text="Button" Visible="False"></asp:Button>
<asp:Button id="Button2" style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 152px" runat="server"
OnClick="btnClick" Text="Button" Visible="False"></asp:Button>
<asp:Label id="lblMsg" style="Z-INDEX: 105; LEFT: 56px; POSITION: absolute; TOP: 32px" runat="server"
Width="288px" Height="60px"></asp:Label>
<asp:HyperLink id="hlWebLink" style="Z-INDEX: 106; LEFT: 56px; POSITION: absolute; TOP: 104px"
runat="server" Width="384px" Height="16px" Visible="False"></asp:HyperLink>
</form>
</body>
</HTML>
Thanks,
Tim
|
|
|
|
|
RegisterStartupScript will register your javascript and will call when form gets loaded. i think you are also calling same function on button click event . What you have to do ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi all,
i have a page with a button on it, onclick of button i need to get a string data from database and need to write that to a word file. my code is like this:-
1) function:- i am calling this function on button click event after getting my data from database, suppose data is a string "someString".
i am bound to use this approach only because of some specific requirements(can't use word file writing with word application and document object...)
private void html2word(string someString)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "application/msword";
HttpContext.Current.Response.Write(@"");
HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename='InvDetails.doc'");
HttpContext.Current.Response.Charset = "utf-8"; //UTF8
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250"); //windows-1250
HttpContext.Current.Response.Write("");
HttpContext.Current.Response.Write(someString); HttpContext.Current.Response.Write(" ");
return HttpContext.Current.Response;
// this flush() line of code will ask user to open or save a word file, here only i want to save this file without prompting the user, as this file is going to be deleted after some operation and hence user should not know that it is created... how can we do this
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily
Akhilesh Singh
|
|
|
|
|
Hi All,
Is there any relationship between Cookies and Session.Abandon()???
Is am implementing Remember Me on this computer on login page and store the user name and password in Cookies. It works fine if I logout from my site but if I close my application and again run then it doesnot maintain the cookie values.
Please help me...
Thanks in advance...
|
|
|
|
|
Hey sorry for late reply
Can you post the code where you are adding cookie from server side
see this it is working fine in my machine sequence should be like this only specially for expiry i think it should work now
<br />
HttpCookie cookie = new HttpCookie(TxtBxUserName.Text);<br />
Response.Cookies.Add(cookie);<br />
cookie.Values.Add("",TxtBxUserName.Text + "|" + TxtBxPassword.Text + ";");<br />
Response.Cookies[TxtBxUserName.Text].Expires = DateTime.Now.AddDays(15); <br />
<br />
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hey Sandeep, many many thanks. Its working fine now. Thanks a lot.
|
|
|
|
|
im sorry...but i dont have much experience in this...
but i think u have to use Sesseion.Clear();
coz the Session.Abandon(); will delete the key of ur web.
regards and replay if it is worked
|
|
|
|
|
Hi,
Please can someone give me help with how i go about creating a (pop-up) confirmation box which is activated on page load. If the client clicks 'ok' i need to redirect them to another page, otherwise they are to stay on the current page.
Thanks in advance.
|
|
|
|
|
this.ClientScript.RegisterStartupScript(this.GetType(), "OnLoad", "confirm('really');", true);
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hi,
How do i add an action if the dialog is confirmed?
Thanks
munklefish
|
|
|
|
|
Instead of writing confirm call a function there in that function write the logic
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Sorry, i dont know what is required.
|
|
|
|
|
this.ClientScript.RegisterStartupScript(this.GetType(), "OnLoad", "functionName();", true);
now write a javascript function
functionName()
{
if(confirm('really do you want...'))
{
write the code when yes is selected
}
else
{
writet the logic when no is seleced
}
}
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
i want to display videos in browser in a website.
any suggestions.........
Do good and have good.
|
|
|
|
|
The easiest way is to use youtube Saves bandwidth
|
|
|
|
|
This all depends on the format of the video as to the exact method.
However it basically intails embedding the appropriate vide player into the html code. This code is available readily on the web, and can be done automatically (i think) via tools such as dreamweaver.
This is assuming you have an pre-encoding video file? If not you will need to encode it to your chosen format using the appropriate encoding tool for the format you wish to use.
However this is essentially quite a basic process, so id be a little concerned that you are asking this in a .Net forum.
munklefish
|
|
|
|
|
hi all
i am buiding page Print image but i dont know how many pixel image if size is A4 or A1, 2,3,4 convert to with and height image
|
|
|
|
|
That's not how it works. You should be able to tell the size of the image the printer can accept, from the printer, and then size your image accordingly. Most printers have huge resolutions, as they are far more than 72 DPI.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
that mean
i am developing module print for map
in the page print u can choose type page so: A4, A3, A2...
when u chose A4 i have set size (width and height) for this image so it accord with type
but i dont know if this A4 or A3 this size of image how much ??
|
|
|
|
|
hi friends
i bind the image in codebehind like this:
but the image is not display
any syntax problem
string bodyHTML = "" +"" + "";
regards
saravan
|
|
|
|
|
Try putting the path in quotes, but it should not matter. Where is the images directory ? Where is this html, relative to that directory ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
This is just a simple case of tinkering with your file paths.
Try:string bodyHTML = "<html><head></head><body>" +"<img src='/images/h.gif'>" + "</body></html>";
Use single quotes around the source location, also try simply putting a '/' before the image location. Some servers are set-up such that they may or not require the prefix of a forward slash.
You could also try using some sort of mappath code to find the true location of your images folder.
munklefish
|
|
|
|