.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Problem with Parameters.AddWithValue and GUID

Posted By:      Posted Date: September 10, 2010    Points: 0   Category :ASP.Net
Hi,have a problem, when i want to update a line in my database with the SQLCommand. I have following code: SqlCommand tmp_sqlcmd = new SqlCommand("UPDATE LogSend SET LogSend = @State WHERE DEVICE_UID = @Device_ID", Default_Con); tmp_sqlcmd.Parameters.AddWithValue("@State", logsend.state); tmp_sqlcmd.Parameters.AddWithValue("@Device_ID", logsend.Device_ID); int test = tmp_sqlcmd.ExecuteNonQuery(); tmp_sqlcmd.ExecuteNonQuery();But nothing happens when the command is executed. Any ideas?When i manually edit the line with:UPDATE LogSend SET LogSend = 1 WHERE DEVICE_UID = '5d8f3da0-e7c9-4a99-bb3f-246ce63ceebb'It works.Any ideas for me?Sincerely,Steven

View Complete Post

More Related Resource Links

Problem with Finder method with parameters



Could someone explain me how to provide some value to the parameters in a finder method. For exemple I know that the BDC list WP use this method. Is there a way to provide some value for those parameter at runtime? I really don't understand (even after some deep search on the web) where are the values for the parameters from and how we can connect to them. Even with C# code I can't find any information on how it work.

I don't want to define my parameters as filter in the ADF because then I will have this filter section in my BDC list WP (or is there a way to get rid of that?). Actually one of the parameter should be automatically calculated from a value in a SP list, the other parameter should be provided by my own filter web part.

Thank you for your help.

MDX problem (Amount value is getiing doubled when multiselecting dimension parameters)

Hello...I need some help with the MDX...basically the problem is the Amount value is getting doubled when I am selecting more than one parameter. Here is situation...suppose I select a parameter  lets say A from dimension Account Element Hierarchy then I get the Budget Amount as $100, now in my SSRS report I change the dimension parameter value to B and then I get the Budget Amount $200. Now I multiselect A and B and ideally I should get the Total Budget Amount as $100+$200=$300 but in place of that I get $600 I have captured the mdx below...Please let me know if you have an idea to fix this --The below MDX returns $100 for Budget Value SELECT   NON EMPTY { [Measures].[Budget Amt], [Measures].[Budget / RSF] } ON COLUMNS, NON   EMPTY { (DESCENDANTS([Account Hierarchy].[Account Hierarchy].[Level 02].ALLMEMBERS) ) } DIMENSION   PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME, PARENT_UNIQUE_NAME, LEVEL_NUMBER ON   ROWS FROM [Finance]   WHERE (STRTOSET("{[Account Element Hierarchy].[Account Element Hierarchy].&[1214|425|406|495|1209|421]}"),   STRTOMEMBER("[Date].[Year].&[2010]"),   STRTOMEMBER("[Budget Version].[Budget Version].&[Budget]"), [Account Hierarchy].[Account Hierarchy Type].&[2])   CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR,   FORMATTED

Problem with Parameters

I'm fairly new to this and appreciate any detailed info you're able to give. I have a report that has two datasets. One dataset queries for possible term code values which is then passed into the second dataset. If I execute the first dataset statement within the report builder, I receive an expected output. If I hard code a value into the "?" parameter location in the second dataset, I receive expected information. It doesn't, however, work correct when previewed. My data source is of the "Oracle" type. Executing the report in the Preview tab results in: An error has occurred during the report processing. Query execution failed for data set 'Banner_FU'. ORA-01036: illegal variable name/number.   What am I missing?   joe

Problem with cheking the sended parameters on sended page

Hi everyone hope u will help me i have some pages, in my first page have  a repeater with hyperlink and i want to send 2 parameters to another page<asp:HyperLink ID="hp1" runat="server" Text='<%# ". Sayi :"+ Eval("sayi") %>' NavigateUrl='<%# "~/arsivdetay.aspx?cilt=" +Eval("cilt") + "sayi=" +Eval("sayi") %>' ForeColor="#FF6600" Font-Bold="True" Font-Underline="False" Font-Size="12px" /> looks fine here atm but the problem start on sended page cs sideprotected void Page_Load(object sender, EventArgs e)        {                        if (!IsPostBack)                if (Request.QueryString["sayi"] == null)                    Response.Redirect("~/default.aspx");                else                    makalegetir(Request.QueryStri

Problem : Need to make COM InterOp at runtime using reflections Passing Pointers as parameters?

Hello, I need to make COM IntetrOp at runtime using reflections. My native COM Object's exposed methods have some parameters as pointers (DWORD*) and some double pointers (DWORD**) and some are user defined types(e.g SomeUDTType objSmeUDTType) and vice versa its pointer(i.e. SomeUDTType *pSomeUDTType). Now for dynamic method invocation, we have single option for passing parameters as array of object i.e object[] and filling this array statically. But I need to pass pointers and references and pointers to pointers. For now how can I be able to populate object array as mixed data of simple data types, pointers or references and pointers to pointers. Working Example: Native COM exposed method : STDMETHODIMP MyCallableMethod(DWORD *value_1,BSTR *bstrName,WESContext a_wesContex Translated by tlbimp.exe (COMInterop) UDTINIDLLib.RuntimeCallingClass.MyCallableMethod(ref uint, ref string, UDTINIDLLib Now calling these methods at runtime using reflection at runtime, See here :        Assembly asembly = Assembly.LoadFrom("E:\\UDTInIDL\\Debug\\UDTINIDLLib.dll");         Type[] types = asembly.GetTypes();         Type type = null;    //foreach (Type oType in types)         {             try      &nb

Interesting problem with getting OUTPUT parameters from SQL Server using C#

 I have the following SP: Create procedure dbo.example(@test INT OUTPUT)ASBEGINSET @test = 5SELECT * from UsersENDGO  and when I try calling it from C# using an SqlCommand with adding an output parameter and getting it's value, I get that the value is NULL. (I should mention that I use ExecuteReader)However,  if I alter the SP and remove the select line, the c# code works and returns the value 5. 

Problem with SELECT COUNT query and parameters

Hello!I have a problem with SELECT COUNT query in ASP.net. I want to create CMS with articles which have categories (which have the option to be deleted). The problem is that I want to get the number of articles within the specified category so if there aren't any articles with the specified category I can proceed with the category deletion.I have the following code:protected void Page_Load(object sender, EventArgs e) { } protected void GridViewKategorije_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Uredi") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow odabraniRed = GridViewKategorije.Rows[index]; TableCell ClanakID = odabraniRed.Cells[2]; string ID = ClanakID.Text; Response.Redirect("/Portal/Administracija/Kategorija.aspx?idKategorija=" + ID); } else if (e.CommandName == "Obrisi") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow odabraniRed = GridViewKategorije.Rows[index]; TableCell KategorijaID = odabraniRed.Cells[2]; String connString = WebConfigurationManager.ConnectionStrings["CMS"].ToString(); SqlConnection conn = new SqlConnection(connString); conn.Open(); using (SqlC

Reporting Services Report Parameters Problem


I have the next table, & I have the Id of the account as a report parameter @AccountID

|account |LastYear |Jan |Feb |Mar |Apr |May |jun |Jul |Aug |Sep |Oct |Nov |Dec |YTD  |Plan
| 00001  | 10.00    |  1   |  2  |  3  |   5 |  32  | 12 | 11| 10  |  8   | 87 | 54  | 54  | 123 | 250

I tried to build a Query that return me

Jan       |  1
Feb       |  2
Mar      |  3 ...

I already tried to build  a temporary table, but then Ignore my report parameter saying Must declare the scalar variable "@AccountID".
But If I eliminate the code of create #Table, The parameter works just fine.


Part of my query is :

Declare @IddeCuenta varchar(50)
set @IddeCuenta =

(Periodo varchar(30),
Informe_Ventas money)

INSERT INTO #VentasGraf VALUES ('LstYear',0)

    UPDATE #VentasGraf
    SET        Informe_Ventas =
    (SELECT  ISNULL(sum(new_acumula

Problem Using Invoke and passing multiple byref parameters


I have code, shown below highly simplified that works all except for 1 thing: The variables being passed byRef get passed, but once modified in RecordData, they are never updated in the calling function. The calling function does not receive the updated data that is in the variables custid and amt. When debugging, I see the data in the else section of if me.invokerequired, but once it returns from the callback and is in the latter part of if me.invokerequired the data is missing.

How do I fix this?


Delegate Sub RecordDataCallback(ByRef custid As String, ByRef amt As Double)

Private Sub RecordData(ByRef custid As String, ByRef amt As Double)
    If Me.InvokeRequired Then

Problem passing parameters to controller


I have a problem with getting a parameter in my controller.
My url is: http://localhost:portnr/News/Details/43

My Global.asax:

    null, // Route name 
    "{controller}/{action}/{newsid}", // URL with parameters 
    new { controller = "News", action = "Details", newsid = "" } // Parameter defaults 

My controller code:

public class NewsController : Controller 
    public ActionResult Details(int? newsid) 
        //some code 

My controller is never getting the value out the url, how can i fix it ?
I don't want to use: /Details?newsid=43

Pass Multi-Value parameters to Stored Procedure problem



I am trying to pass multi-value parameters to stored procedure to filter data, but seems it does not work.

Stored procedure:


ALTER PROCEDURE [dbo].[test]

@StartDate DateTime,
@EndDate DateTime,
@FirstName varchar(8000),
@LastName varchar(8000),
@Location varchar(8000),

SELECT [Item No_],[Sales Staff],[Location Code],[Date],
[Price],[Quantity],[Item Category Code],[Product Group Code]FROM [Trans Sales Entry]
cte2 as
SELECT [ID],[First Name],[Last Name] FROM Sta

Interesting problem with getting OUTPUT parameters from SQL Server using ASP


I had an sqldatasource. I had set its parameter as follows

<asp:SqlDataSource ID="FvDs" runat="server"
InsertCommand="INSERT INTO [Type] ([ShortName], [LongName], [Version]) VALUES (@ShortName, @LongName, @Version);

Then i had retrived the value in OnInserted event of the datasource

protected void FvDs_OnInserted(object sender, SqlDataSourceStatusEventArgs e)
        FvDs.SelectParameters["ID"].DefaultValue = e.Command.Parameters["@ID"].Value.ToString(); 

For the above code it is working fine.

But now i changed the code as follows:

<asp:SqlDataSource ID="FvDs" runat="server"

and here is the code for my stored procedure

ALTER PROCEDURE dbo.usp_InsertData
	@ShortName varchar(20),
	@LongName varchar(50),
	@Version varchar(20),
			INSERT INTO [Type] ([ShortName], [LongName], [Version]) VALUES (@ShortName, @LongName, @Version)

Linq: how to share parameters between lambda expressions ?

When using Linq to objects, you will quickly feel the need to pass some parameters from a method to another but it's not so easy because each Linq method is not calling the following one. In a Linq sequence, each method is using the result computed by the previous one. So, local contexts are not visible from one method to another.
The compiler is using two technical different ways to let parameters go out of a method.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Regrading Sharpoint 2010 problem and solutions

We can write your question and problem on this blogger.you get ans.use.

This sharpoint 2010 problem solving threads

Hi friend,

you can use this thread to solving problem and solutions.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend