ADO.NET :: Passing String Variable To SQL
Feb 22, 2011I have this string variable:
[Code]....
I want to pass the string MON to the sql query: to replace trunc(sysdate) .
[Code]....
I have this string variable:
[Code]....
I want to pass the string MON to the sql query: to replace trunc(sysdate) .
[Code]....
I have this sub in a class modulePublic Shared RunMySub(ByVal P as Page) 'I need page ref in the class sub to clear cache like
P.Cache.Remove("MyCache")
end sub
When I call this sub 'RunMySub' from a page, it works fine, ok, great !BUT now I need to run it from another class module...so I did this
Dim mpage As New Page
RunMySub(mpage)
mpage = Nothing
I get the error : Cache not available...How can I pass a page from another class module , thats not a page, or some how manage cache functions on a class module without pass the page varible ???
I just need to know how to pass a javascript variable to c# when i click on a button
View 2 RepliesI am thinking this is a pretty simple problem... but I can not get it to function.I just want to get the calendar control to change a date which subsequently modifies a database select statement. I can get the current code to process without error, but the variable set is always a click earlier. Of course, I want the variable to be set upon any change in the calendar control.
public partial class NewBusinessReport : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
[code]...
Does this make sense? I just want it so that when SelectionChanged gets fired the Calendar1SelectCommandDate passes the correct date to the Page_Load page. The error I get now is:"The name 'Calendar1SelectCommandDate' does not exist in the current context"I get that the variable does not exist in the context. That actually seems to make sense based on what I have coded; however, I try to get that variable established and I still seem to be headed in the wrong direction.Basically, I have four calendar controls, one for a date (period 1 start, end and then period 2 start, end). I want to set the program so any change in that date sets off a new Select statement into the SQL server.
I hope this is simple but I can't find any information when searching Google about passing a variable between two Protected Subs.
When I use the fileUpload tool within my webform I need to take the filename chosen and use it in a different Protected Sub
want to use the value of a variable on to the other page, what i am supposed to do for that.i am novice at asp.net
View 8 RepliesI am trying to pass a variable within a selectcommand statment in ASP.NET and I have researched online how to do it but I can't seem to find a way to do it...What I am trying to do is write a code for a web page that will display a page with useful links on it where the links are separated into different topics and where everything is dynamically grabbed from a database. This is what I have so far:
<!-- Start MainContentRegion -->
<h1>Useful Links</h1>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
[]code...
protected void saveMergedFile(string[] ReportFiles)
{
foreach (string item in ReportFiles)
{
[code]...
I am using ASP.NET MVC 3 and the YUI library.I created my own helper method to redirect to an edit view by passing in the item's ID from the Model as such:
window.location = '@Url.RouteUrl(Url.NewsEdit(@Model.NewsId))';
Now I am busy populating my YUI data table and would like to call my helper method like above, not sure if it is possible because I get the item's ID by JavaScript like:
var formatActionLinks = function (oCell, oRecord, oColumn, oData) {
var newsId = oRecord.getData('NewsId');
oCell.innerHTML = '<a href="/News/Edit/' + newsId + '">Edit</a>';
};
I have 10 hyperlink controls. Depending on which hyperlink is pressed I want to pass a value to the target page. I think the easiest way would be to pass the value using URL of the hyperlink controls. Something like <asp:HyperLink ID="HyperLink1" NavigateUrl="~/News.aspx?id=>. I can pass just a value, but I want to pass a value from a variable.
<asp:HyperLink ID="HyperLink1" runat="server"
I need to make the connection string in my vb.net web application be passed into the app externally. This is so I can re-driect the app to use either a test or production database. The same idea as a .INI file in a windows base system. someone suggested to me I use XML but I dont know how to do that.
View 13 RepliesI cant get this right
[Code]....
Where PKey is a variable that holds the Datakey
I have a SQL stored procedure on a SQL server that uses a variable to create a new database. This works in SQL I have a connection string that works I have added a sqldatasource to a webform, and configured the datasource to connect to the remote SQL database and am able to select my stored procedure. I am able to bind the variable to a control in the sqldatasource wizard (often two of the same control appear- if that is significant)
When I test the sqldatasource in the configuration wizard and put in a manual entry, the procedure runs and works
It is on the web page I am having troubles. I want the user to enter a name in a text box, click a button/link, and run the procedure. Ive used buttons and links...but not in the right way I think, becuase when I click them the stored procedure doesnt run.
As mentioned above, I have selected the right control in the sqldatasource wizard. So what do I need to do now?
Is it button click event? If so whats the syntax?
Should I be embedding my textbox in a dataview?
I am using ASP.NET 2.0 and C#. I have a gridview, which has a datanavigateurlformatstring, in which i am passing data in the gridview as querystrings.I have a hiddenvariable in the page. i would like to pass the hidden variable to the gridview in the datanavigateurlformatstring.Currently i have the gridview and hidden variable like this:
[Code]....
How to pass the hiddenfield value in the datanavigateurlformatstring?
can I pass a variable from code behind to a javascript function. if so, do you have a sample demo.
View 1 RepliesI have a value in string i want to use that value on next page.
How can i access it with previous page property?
Or is there any other way to fetch value store in string variable on next page?
How to display the string data stored in a string[] variable into gridview?
View 9 RepliesI am trying to add a string to an SQL statement based on whether an asp:checkbox is checked. Below is what I have, and it isnt working.
I know I could set comm inside the if statement, but I imagine there is a way just to add a variable string to the SQL.
Quote:
string IndCBSQL;
if (iIndividualsCheckBox.Checked)
{
IndCBSQL = "AND CMMaster.CONSTTYPE LIKE 'Individual'";
[code].....
Passing onto a stored procedure a value from a GridView. The particular fields are a date type, and numeric type. Problem is, its plausible and conceivable in this case one or both could be null or empty.
Through searching I've seen suggested such ideas as Convert.ToDate(value), CDate(value), and so on.
None of these work. You cannot convert an empty string or null value to a date. I don't know about the numeric value.
So, barring any non-working examples already given. What is standard. Its not like I've stumbled across some never afore seen problem.
Here is my code, but its quite typical.
Dim txtctlHireDate As TextBox = CType(gvEvaluatees.Rows(e.RowIndex).FindControl("txtHireDate"), TextBox)
Dim txtctlGradYear As TextBox = CType(gvEvaluatees.Rows(e.RowIndex).FindControl("txtGradYear"), TextBox)
Dim txtctlBU As TextBox = CType(gvEvaluatees.Rows(e.RowIndex).FindControl("txtBU"), TextBox)
Dim ddlctlEvalGroups As DropDownList = CType(gvEvaluatees.Rows(e.RowIndex).FindControl("ddlEvalGroupSelection"), DropDownList)
Dim chkctlActive As CheckBox = CType(gvEvaluatees.Rows(e.RowIndex).FindControl("chkActive"), CheckBox)
UpdateEvaluatees.MGEvalUpdateEvaluatee(gvEvaluatees.DataKeys(0).Value, txtctlHireDate.Text,
txtctlGradYear.Text, txtctlBU.Text,ddlctlEvalGroups.SelectedValue, chkctlActive.Checked)
gvEvaluatees.EditIndex = -1
gvEvaluatees.DataSource = EvaluateesForDataGrid.GetData
gvEvaluatees.DataBind()
I've bolded the parameters in question. A date value and numeric value are expected.
Ok, so it's easy in VB, but I can't figure it out in C#:
SqlCommand cmd = new SqlCommand("SELECT COUNT(*) FROM tblUsers WHERE username = '" & username & "'", cn);
This throws
CS0019: Operator '&' cannot be applied to operands of type 'string' and 'string'
<img src="http://track.opicle.com/aff_l?offer_id=2193&adv_sub=LEAD_ID" width="1" height="1" />
var x ;
x Should be replace at the place of LEAD_ID
<img src="http://track.opicle.com/aff_l?offer_id=2193&adv_sub=x" width="1" height="1" />
Meas var x will replace at the place of Lead_ID
I tried to pass a string value into a JavaScript function like below: <%= "'" + prop.property_description + "'") %>) But it does not seems to be the best option, is there a better way to do the above without concatenate the string values with "'"?
View 2 Replieshow to pass through a query string parameter of an assignment id and then checking and validating this as a number and displaying the information returned on screen. At present I have code which displays the information on screen but this is by entering in the assignment id and by triggering the button click event, I've shown the code for this below:
.aspx
<div>
<b>Current Assignment</b>
<br />
<asp:TextBox runat="server" ID="txtAssignmentID"></asp:TextBox>
<asp:Button runat="server" Text="Get Assignment" />
<br />
<b>Date Started:</b> <asp:Label runat="server" ID="lblAssignmentStart"></asp:Label>
<br />
<b>Status:</b> <asp:Label runat="server"></asp:Label>
<br />
<b>Current Achievement Level:</b> <asp:Label runat="server" ID="lblAssignmentLevel"></asp:Label>
<br />
<b>Date Last Calculated:</b> <asp:Label runat="server" ID="lblAssignmentCalcDate"></asp:Label>
<br />
</div>
.cs
protected void cmdGetAssignment_Click(object sender, EventArgs e)
{
//Check the assignmentID is an integer
int AssignmentID = 0;
try
{
AssignmentID = TypeConv.CInt(txtAssignmentID.Text);
}
catch
{
}
if (AssignmenttID > 0)
{
//Create new TCAAssignment object by passing the ID
TCA Assignment Current Assignment = abc.TCA Assignment (AssignmentID);
lblAssignmentStart.Text = Current Assignment.dDateCreated.ToString();
lblAssignmentStatus.Text = CurrentAssignment.rTCAAssignmentStatus.dDescription;
if (!CurrentAssignment.dTCAAchievementLevel.IsNull)
{
lblAssignmentLevel.Text = CurrentAssignment.rTCAAchievementLevel.dDescription;
}
lblAssignmentCalcDate.Text = CurrentAssignment.dAchievementDate.ToString();
}
}
Code example passing through a query string parameter of an assignment id would be great.
I would like to pass a query string for example [URL]to my webservice below. I would like to get that "id" and pass it to the getmsg method.
public string GetChatMsg(string sGUIDParam)
I am using a third party Web Service. I am passing a string to a function in that service, that string, which i am reading from a UTF-8 text file. The problem it that the string contain some non ASCII characters.
Now if i save that text file to ANSI format, read it in a string and pass that string to Service then it works smoothly but with UTF-8 encoded string the service throw exception [Code]....
NON ASCII characters UTF-8 encoding SOAP
I am using ASP.NET.
Third party sevice is in java. I also tried it by making a web service in .net, but there was issue there too.