DataSource Controls :: Strange Behavior Of Cmd.ExecuteScalar()?
Jul 27, 2010
I have a simple procedure which updates a table. The procedure works fine and I have tested it in Management Studio. However when I am calling that procedure from code, nothing is happening. cmd.ExecuteScalar returns null when it should return the ID.Has anyone faced anything similar? Any pointers as to how this can be resolved?
I have a site that was sucesfully upgraded to Framework 3.5 on Vista with VS2008. Now however after installing VS2010 and upgraded to Win 7 wierd things are happenning and was wonderring if any of you have experienced this and how you've dealt with it.First thing I notice in my main page that the four user controls are not in alignment. They should appear side by side in a single row, however now they spread acros two rows with one on top and three on the bottom. Also my graphics and navigation is not where they supposed to be. Just for comparison, if run the existing solution on Win 2003 with VS2008, it works like it supposed to. All the formatting is handled in .css and that didn't change either.
the javascript is working perfectly and changes the value of the textbox.the problem happens when i submit the form - what is extracteed by the model from the textbox is the string "on", and after the submit, it also changes the value of the textbox to "on".when i load the field with a value from the model, it goes ok, and does not change
I've got a user control that is displayed via a PopupControlExtender. The user control is a GridView that dynamically adds columns to the control to display the results of a SELECT statement. The PopupControlExtender correctly displays the control and the control displays the neccessary columns. However, when the control is first displayed, the column widths are ignored, despite that they are explicity set. If the control is displayed and then hidden, the column widths are acknowledged the next time the control is displayed.
I have strange behavior when changing from ItemTemplate to EditItemTemplate. both the ItemTemplate and EditItemTemplate contain the same textbox with multiline. Except the ItemTemplate got the ReadOnly parameter. When the row is getting in EditMode and I enter the textbox everything is disabled. I click on another column that contains a label instead of a multiline textbox and get back in the textbox I can do everything. When I enter in the same row another MultiLine textbox I cannot do anything until I click on a label and get back in that TextBox. When the textboxes are in normal mode I don't seem to be having this issues. What is changed between the MultiLine and SingleLine textbox? What kind of PostBack or something could cause this strange behavior?
I have a page with 14 dropdown lists. In the first page load (ie. not isPostback) I set the selectedIndex of the dropdownlists individually but I find that they are all set to the value I use for the last dropdownlist set. Here is the code
comboFirstJudge1.SelectedIndex = 0 comboFirstJudge2.SelectedIndex = 0 <so on for all the dropdown lists until the last one> comboFirstJudge14.SelectedIndex = 4
The result is that all dropdown lists have SelectedIndex = 4. If I run the same code on a postback it works just fine (the first lists have SelectedIndex = 0 and the last one = 4).
I have an issue that seems to only happen on my production server. I show or hide table rows whenever the buttons are clicked. However, when I do a postback on the checkbox, all of the rows become visible and the textbox stays empty. It works correctly on my test server and local workstation, just not in production.
Here is the markup...
[Code]....
Here is the code behind...
[Code]....
Here are the unexpected results whenever I check the chkShow2 checkbox... I am guessing this is a configuration issue on the server.
Since both retruns the value. Then whats is the difference between ParameterDirection.ReturnValue and ExecuteScalar()
int i = Convert.ToInt32(cmd.ExecuteScalar()) objCmd.Parameters.Add("@ColumnnTest", SqlDbType.Decimal).Value = objPropertiesClassName.Columnnumeric; objCmd.Parameters["@Columnnumeric"].Direction = ParameterDirection.ReturnValue; objCmd.ExecuteNonQuery(); int i = (int)objCmd.Parameters["@Columnnumeric"].Value;
I developed a website using asp.net 2.0 and sql server 2005. I m using Turkish language content as entries to database tables. But when I try to add any record from my web interface I see strange characters. for example "ş,ğ,İ," characters are viewed like Å,? characters. I set my globalization to culture turkish in web.config. So there s no problem with static data on the page and no problem with records I added earlier in my own machine. I just need to send data in a correct encoding to the database.I first thought it was about collation, but changing collation doesn t differ data sent to database, I think I need to do something from my web app, but still couldn't get any ideas.
i expect it to fail at 101 iteration as the default max pool size is 100 and i am not releasing any connection after i open(ie., Not closing or Disposing). But the strange behaviour is i can go up to 230 iterations and then it gives me a timeout error, can not acquire new connection.
When i look in SQL Database for number of connections created it is only 100.
My question is : When connection is not released, how is it able to re-use the previously opened connection.
I have this SQL Select statement to select the basket id where the user id equals a specific ID.I want to store the result of the query in a variable, so I thought I could have done:
BasketPage.SelectCommand="SELECT BasketID FROM tblBasket WHERE (UserID = '9f96bd94-91b9-4328-8214-4eac179c3a26')" var BasketID = BasketPage.ExecuteScalar().ToString();
But apparently I need to create a new instance of an SQL Command for it to work, how can I do this for the BasketPage Select Command?
I have the SqlCommand Problem. cmd is the sqlcommand and when run cmd.Executescalar(), what will it return?? As I have the problem below code that it always prompt invalid cast which may be in the assigning BAtchno. What do you think?? How to Correct below code?? --------------------------------------------------------
sSQL = "select max(batchno) from QI_WMS.dbo.WMS_StockRelease_Shipment with(nolock) " + " where convert(varchar, SRDate, 111) = @DateReceive and WarehouseID=@WarehouseID";
I know for a fact that the SQL statement below returns NULL but my code statement "if (obj != null)" is not working.When I debug it I see a value of {} ... not sure what that is. Here is my code:
[Code]....
So, even if SQL returns NULL, it still validates obj as NOT NULL !
I posted a question about how to save the result of an SQL command to a variable and was told that the execute scalar method should be used, however I can't use it, I'm using the System.Data.SQLClient reference but still not finding it
I am using following oracle query and using executescalar() to fetch data
sql = "select username from usermst where userid=2" string getusername = command.executescalar(); But It is showing me error "System.NullReferenceException: Object reference not set to an instance of an object" This error comes when there is no row exist in database for userid=2
I may just thinking wrong about this but I have a problem that is causing me to want to pull my hair out:
I have two DropDownLists. Call them ddl1 and ddl2. I am binding ddl1 to a DataTable on page_load using if not IsPostBack and allowing view state to keep it populated.
I am then binding ddl2 to another DataTable based on the selected item in ddl1 on the SelectedIndexChanged event on ddl1. My problem is that when I set ddl2's AppendDataBoundItems="true", it just appends the items in the DataTable each time I select a new ddl1 item, so that if I change the selected item in ddl1 3 times, I end up with items in ddl2 from the 2 previous selections as well as the current ddl1 selection.
This doesn't happen when I set ddl2's AppendDataBoundItems="false". Obviously, this is not desiariable behaviour.
I hope this is the right forum for this question.The statement , object obj = cmd.ExecuteScalar() is returning 2010-10-22 18:25:36However is not bringing the last 3 digits (miliseconds).This is actually calling the following SQL query: select max(timeStamp) from Table1 which returns 2010-10-22 18:25:36.713 on query analyzer. As you can see "713" is not being included ...How do I bring this value?
I have a asp:button in template field of gridview, I set command name for this and in grid I mention on command event. On clicking the page it shows error message is :Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/>
I am trying to implement a online shopping Cart which enables editing and deletion of products. I created a datatable programatically and bind it to a Griview control. (datatable is stored in a session variable ). When clicking the edit button of the Gridview nothing happened. How can I impement editing behaviour to the gridview?