Databases :: Getting A Textbox Variable Into A Sql "where" Statement / Doesn't Seem To Be Working
Dec 18, 2010
I am trying to pass a textbox integer to a sql statement in my code behind using the "where" statement to filter what I get from the mysql database but for some reason, it diplays nothing. If I change the variable in the "where" statement to an actual digit between 1 and 12, it works.
Here's my code:
Default.aspx:
[Code]....
Default.apsx.cs:
[Code]....
View 4 Replies
Similar Messages:
Mar 21, 2010
On Page1 of a project, I have a Gridview showing a table of customer names (showing CustID, CustName, CustJoinDate). When I click on a record, I have passed a querystring to Page2 showing an address table for that customer. This part works for me.
The SQL statement in simply: Select * from CustAddress where CustID = @cust
What I would like to do though, is capture that @cust to a session variable so that I can use it later on.
View 2 Replies
Jul 14, 2010
In asp.net,When I type letter in textbox, textbox doesn't show this letter and save in variable and when i type digit in textbox, textbox shows this digit and store in another variable. How should i do?
View 4 Replies
Feb 24, 2011
Why can't I set a variable within an If statement and use it outside? The following doesn't work - in the last line - variable unassigned???
[Code]....
View 2 Replies
Mar 9, 2011
I'm converting a string to integer and than inserting this integer in my post table.
int currTopicID = Convert.ToInt32(id.Text);
SqlCommand cmd = new SqlCommand("INSERT INTO post VALUES(currTopicID)", con);
The problem is that currTopicID isn't being recognized as an integer when i do the insertion.
View 4 Replies
May 10, 2010
I have a select statement where I want to get some data. The problem is that I am not geting the right answer. This is what I am trying to do:
SELECT * FROM se_cs_test WHERE
Status = 1
OR Status = 2
AND NumberOfContacts = 1[code]...
View 2 Replies
Jun 10, 2010
"SELECT a.fibunr, " & _
View 14 Replies
Nov 29, 2010
at present our site has a search function which then populates a grid with results from our catalogue database... I'm trying to implement product availability into the grid, but the stock information is stored in a completely different database in a different location. Both the main search results and the stock levels have to be referenced in the same datasource to get them both in the same grid; does anyone have any thoughts on how to do this? I'm not hugely experienced with SQL, but could I create a view containing aspects of both db's or are these limited to a single db?
View 3 Replies
May 27, 2010
I'm having problem getting the syntax right for an SQL statement for a Progress database. I have the column "Resource" which is a reserved word and according to the Openedge SQL Reference I can only use reserved words if I delimit them with double quotation marks.
So how do I write this line...
Dim comm As New OdbcCommand("SELECT Resource FROM PUB.ActOper WHERE CreDate > TO_DATE ('05/24/2010')", conn)
...with double quotes around Resource? I've tried a bunch of different combinations but I get "Expression expected" or "valid continuation expected" or something similar.
View 4 Replies
Mar 25, 2010
I've done some SSIS package work in the past, but am by no means an expert.
I want to use an SSIS package to do the following:
1. Get the file name of the newest file in a windows folder (using a filename template like his: filename_ *.txt where the * part is always a date in the format of yyyy-mm-dd.
2. Use that file name in later portions of the SSIS package by reading the file and transferring data from it to a SQL table using a Data Flow task.
and use the result (which should be the name of the newest file) to open that file and pull data out of it and into a 2nd SQL table. I admit, I'm not sure how to use the dynamic result of this SELECT query as the file name in a flat file connection manager.
View 6 Replies
Oct 21, 2010
I am rather confused as how or where to declare this variable in asp.net.
[Code]....
Whenever i put this in my sqldatasource for it is asking me to Define Parameters:
The wizard has detected one or more parameters in your SELECT statement. For each parameter in the Select Statement, choose a source for the parameter's value.
View 4 Replies
Jan 7, 2011
This should be really simple and I am new to asp development.
I am using ASP log in controls..when user logs in, I am storing the userid in a session variable. On this another page, I want to put the previously stored session variable value into a table using Insert statement.
in my sqldatasource..here is the code..
InsertCommand="INSERT INTO tblMain(PatientId, UserId, IncAge, IncDeNovo, IncAnginaIschemia, IncNative, IncLesions, IncStudyConform, IncStenosis) VALUES (@PatientId, @UserId, @IncAge, @IncDeNovo, @IncAnginaIschemia, @IncNative, @IncLesions, @IncStudyConform,
@IncStenosis)">
View 2 Replies
Nov 27, 2010
OK So I know WHY I am having the error I am getting. I don't know HOW to fix it. Basically, if the user doesn't have a certain permission, I need to join another table. But .NET is so picky I can't just make two different queries in an IF statement and then use it outside of the if statement. I can think of some ugly work arounds for this, but I would rather not. I am fairly new to .NET I know just enough to be dangerous.
[code]....
I get the error: Unable to cast object of type
'System.Data.Linq.DataQuery1[VB$AnonymousType_111[System.Guid,System.String,System.String,System.String,System.String,System.Nullable1[System.DateTime],System.Nullable1[System.DateTime],System.Nullable1[System.Guid],System.Nullable1[System.DateTime],System.Nullable1[System.Guid],System.Nullable1[System.DateTime]]]' to type 'System.Collections.Generic.IEnumerable`1[Ten11CRMLib.Company]'.
because of this: Dim l As IEnumerable(Of Company) its not just IEnumerable of a Company, its got the source in it. I have to explicitly select source to use it in my datagrid. Can I make Dim l something that will make it stop complaining?
View 2 Replies
Dec 15, 2010
actuly my site is working fine but suddenly site is giving "ORA-24338: statement handle not executed" this error i'm try to resolve this error but i could not get proper solution
my prblm is tht when i access my site on my PC using "www.xyz.in" at tht time i access my site with report properly but whn i access my site on out of company or any cyber cafe or other internet pc thn i could nt access my site properly tht site is give me error.......
ORA-24338: statement handle not executed
i'm use oracle10g & database connection in "system.data.oracleclient" & most imp thing i;m using site number of years
View 1 Replies
Jun 21, 2010
how to get the sql statement query or table name if oledbexception occurs - table or view does not exists.
get the DB details from the oledb exception.
View 1 Replies
Sep 7, 2010
I'm trying to read Excel file header column name. Then I can query data from excel using SELECT statement. For instance. column name is name,
department and email. Then I want this three header name being detected using code and put in select statement. User no need to care about the
header name and we can use code to read the header name instead of hardcode header name inside SELECT statement.
View 1 Replies
Mar 5, 2010
I am having trouble with this I have 3 Data tables i use over and over again which are cached I would like to write a LINQ statement which would do the following is this possible?
T-SQL VERSION:
SELECT P.[CID],P.[AID]
,B.[AID], B.[Data], B.[Status], B.[Language]
FROM MY_TABLE_1 P
JOIN
(
SELECT A.[AID], A.[Data], A.[Status], A.[Language] FROM MY_TABLE_2 A
UNION ALL
SELECT B.[AID], B.[Data], B.[Status], B.[Language] FROM MY_TABLE_3 B
) B on P.[AID] = B.[AID]
WHERE B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1 AND B.[Language] = 'EN' OR B.[Language] = 'ANY' AND B.STATUS = 1
Then i would like it to create a result set of the following
Results:
|CID|AID|DATA|STATUS|LANGUAGE
View 3 Replies
Sep 17, 2010
I wrote a statement such that
cmd ="select [title] from products where sku='% "3.5 caddy" %'"
this statement wont return anyfin where there is products with titles startin with 3.5 or ending with caddy or containing 3.5 caddy but just not together for example there is this title "3.5" IDE to USB 2.0 Aluminum External Silver HDD Enclosure Caddy" and that search of 3.5 caddy wont pick this item up as 3.5 is at the start and caddy is at the end.
View 1 Replies
May 8, 2010
I have written a bunch of T-sql code to my accessdatasource selectcommand. But I am having problem with where statement ! here is my code;
SELECT OWGBP, RTGBP, OWEUR, RTEUR, OWYTL, RTYTL, (SELECT Resort FROM Resort RF WHERE (View = True) AND (RF.ResID = TypePrices.ResID)) As Resortİsmi, (SELECT Destination + ' - ' + CodeOfDest FROM Destination TD WHERE (View = True) AND (TD.DestID = @DestID))
As DestIsmi, (SELECT TypeOFTrf FROM TRFTypes WHERE (TRFTypes.TRFTypeID = TypePrices.TypeOfTRF)) As TrasferTürü, @QADT As ADTSayi, @QCHD As CHDSayi, ([CHDPerCent]/100) As PerCHDCent, (ADTSayi ++ CHDSayi) As Deger, ResID FROM TypePrices WHERE ([View] = True)
And (ResID = @QRes) AND (Deger >= [MinReq]) AND (Deger <= [MaxCap])
And here is my select parameters;
[Code]....
It is a bit long ! I am having problem on last two where declaration. here ;
(Deger >= [MinReq]) AND (Deger <= [MaxCap])
those MinReq and MaxCap columns are int32 columns. But when I run the page it doesnt work properly ! It display the valuse it shouldn't be ! weird thing is, when I display this 'deger', I get the value properly. with this;
Değer : <b><asp:Label ID="Label10" runat="server" Text='<%# Eval("Deger")%>'/></b>
for example I get 8 with this but it dosnt work on where statement.
View 13 Replies
Jul 8, 2010
How do I store an Eval in a variable or use the value of the Eval in an if statement?
View 5 Replies
May 26, 2010
I am new to all this, and ignorant beyond compare. I believe I have the same problem as this :
[URL]. However, the solution proposed for him doesn't seem to work for me. I have a session variable that 'march_cpi_session' that I wish to include in an sql select statement to multiply the values I get from a datatable before they're used to populate a gridview control. The session variable works fine elsewhere in my application, but causes a variety (depending upon how I fiddle about with the syntax) of sql errors. This is the currrent code:
[code]....
View 3 Replies
Jan 28, 2011
I need to run a select statement on log in event and store the value of the select statement (returning one item) in a session variable.Do I have to u sqldatasource for this.. or is there someway I can run a single select statement and store the resulting value in a variable?
View 7 Replies
Apr 4, 2011
I have a GridView and on a row being deleted I trigger the GridView1_RowDeleting sub, but I receive an error "LINQ to Entities does not recognize the method 'System.Web.UI.WebControls.TableCell get_Item(Int32)' method, and this method cannot be translated into a store expression." Code is:
Private Sub GridView1_RowDeleting(sender As Object, e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GridView1.RowDeleting
' The deletion of the individual row is automatically handled by the GridView.
Dim dbDelete As New pbu_housingEntities
' Remove individual from the bed.
Dim remove_bed = From p In dbDelete.Beds _
Where p.occupant = GridView1.Rows(e.RowIndex).Cells(3).Text _
Where p.room = GridView1.Rows(e.RowIndex).Cells(6).Text _
Where p.building = GridView1.Rows(e.RowIndex).Cells(5).Text _
Order By p.id Descending _
Select p
remove_bed.First.occupant = ""
dbDelete.SaveChanges()
' Increase number of open spaces in room.
Dim update_occupancy = From p In dbDelete.Rooms _
Where p.room1 = GridView1.Rows(e.RowIndex).Cells(6).Text
Where p.building = GridView1.Rows(e.RowIndex).Cells(5).Text _
Select p
update_occupancy.First.current_occupancy = update_occupancy.First.current_occupancy - 1
dbDelete.SaveChanges()
End Sub
The specific line erroring out is: remove_bed.First.occupant = ""
View 2 Replies
Mar 27, 2011
how to create variable with max size in pls/sql function
View 2 Replies
Feb 8, 2010
I'm making a simple forum using MySQL and I use a repeater to display a list of all threads in it. I have two tables for posts, one for threads and one for replies, and I want to sort the threads by either when they were posted or when the last reply was posted in it. My SQL query is really long and hard to read so here's some psuedo code similar to it (easier to understand these column names, etc):
SELECT
threads.id,
threads.title,
threads.timestamp,
users.username,
(SELECT COUNT(*) FROM replies WHERE thread_id = threads.id) AS number_of_replies,
(SELECT COUNT(*) FROM views WHERE thread_id = threads.id) AS number_of_views,
(SELECT timestamp FROM replies WHERE thread_id = threads.id ORDER BY timestamp DESC LIMIT 1) AS last_reply_timestamp
FROM threads
LEFT JOIN users
ON threads.user_id = users.id
ORDER BY ************** DESC
What I do here is I fetch the values id, title, timestamp, the author's username, the number of replies and views for a specific thread, and I also get the timestamp for the last reply to this thread.
Then, what I want to do is sort the whole list so that the threads are displayed in an order matching when either it was posted or the last reply was posted in it (you know, like a normal forum) but I'm not sure how to accomplish this.
I tried this:
ORDER BY CASE WHEN last_reply_timestamp > threads.timestamp THEN last_reply_timestamp ELSE threads.timestamp END DESC
but that, I guess, maybe only looks at the first row and determines which one should be used so the order is not correct.
I'm not sure if it's possible to create a sort of variable that holds the value for each row of the timestamp that applies, if that's possible you could sort by that. For example:
(CASE WHEN last_reply_timestamp > threads.timestamp THEN last_reply_timestamp ELSE threads.timestamp END) AS last_activity_timestamp
...
ORDER BY last_activity_timestamp DESC
So each row has a field "last_activity_timestamp" containing either timestamp, whichever is the later than the other.
Can this be done somehow? How does everyone else solve this? It's so hard to search google because I just get lots of forums but no code.
View 6 Replies