Thursday, March 22, 2012
on parameters
I have 3 parameters-
columnname -takes the column name like name, course, marks
operator - takes the operator - <.>.<= value - takes the value like 30,computers , english etc
i want to pass these parameter to a table and filter the value out.
how can i make the operator as a parameter ?
in the filter expression -
i can give in the column name - column parameter
value - value parameter
but how do i give the operator ?
Thanks
RPIlJQIiA8UlBAZGlzY3Vzc2lvbnMubWljcm9zb2Z0LmNvbT4gd3JvdGUgDQo+IEkgaGF2ZSAzIHBh
cmFtZXRlcnMtDQo+IGNvbHVtbm5hbWUgICAtdGFrZXMgdGhlIGNvbHVtbiBuYW1lIGxpa2UgbmFt
ZSwgY291cnNlLCBtYXJrcw0KPiBvcGVyYXRvciAtIHRha2VzIHRoZSBvcGVyYXRvciAtIDwuPi48
PQ0KPiB2YWx1ZSAtIHRha2VzIHRoZSB2YWx1ZSBsaWtlIDMwLGNvbXB1dGVycyAsIGVuZ2xpc2gg
ZXRjDQo+IA0KPiBpIHdhbnQgdG8gcGFzcyB0aGVzZSBwYXJhbWV0ZXIgdG8gYSB0YWJsZSBhbmQg
ZmlsdGVyIHRoZSB2YWx1ZSBvdXQuDQo+IGhvdyBjYW4gaSBtYWtlIHRoZSBvcGVyYXRvciBhcyBh
IHBhcmFtZXRlciA/DQo+IGluIHRoZSBmaWx0ZXIgZXhwcmVzc2lvbiAtDQo+IGkgY2FuIGdpdmUg
aW4gdGhlIGNvbHVtbiBuYW1lIC0gY29sdW1uIHBhcmFtZXRlcg0KPiB2YWx1ZSAtIHZhbHVlIHBh
cmFtZXRlcg0KPiBidXQgaG93IGRvIGkgZ2l2ZSB0aGUgb3BlcmF0b3IgPw0KDQp0cnkgdG8gd3Jp
dGUgeW91IHF1ZXJ5IGFzIHN0cmluZy4NCkluc3RlYWQgb2YgDQpTRUxFQ1QgKiBGUk9NIGR1bW15
IFdIRVJFIC4uLi4NCndyaXRlDQo9IlNFTEVDVCAqIEZST00gZHVtbXkgZCBXSEVSRSAiICtQYXJh
bWV0ZXJzIXBBZ2VudENvZGUuY29sdW1ubmFtZSAgKyBQYXJhbWV0ZXJzIXBBZ2VudENvZGUub3Bl
cmF0b3IgKyBQYXJhbWV0ZXJzIXBBZ2VudENvZGUudmFsdWUgDQo=|||b29wcw0KcXVlcnkgbXVzdCBsb29rIGxpa2UgdGhpczoNCg0KID0iU0VMRUNUICogRlJPTSBkdW1t
eSBkIFdIRVJFICIgK1BhcmFtZXRlcnMhY29sdW1ubmFtZS52YWx1ZSArIFBhcmFtZXRlcnMhb3Bl
cmF0b3IudmFsdWUgKyBQYXJhbWV0ZXJzIXZhbHVlLnZhbHVlIA0K
Thursday, March 8, 2012
.Net passing bad formatted value to stored procedure
Hi, that's the problem:
I have a GridView, bound to a SQLDataSource, with an stored procedure as a Select query. The Select Parameters are bound to controls in the web form, acting like some filter fields.
When I submit the page, everythings works fine, except when I try to set some value in the DateTime fields. .Net is enclosing the date with extra single quotes, as I could see in the Profiler:
exec sel_despesa_procura @.codigo=NULL,@.fornecedor=NULL,@.descricao=NULL,@.vencto_ini=''2005-10-10 00:00:00:000'',@.vencto_fim=''2005-10-20
00:00:00:000'',@.pagto_ini=NULL,@.pagto_fim=NULL,@.valor=NULL,@.valor_pago=NULL,
@.centro_custo=NULL,@.pago=N'0,1'
The fields are defined as follows:
<SelectParameters>
...
<asp:ControlParameterControlID="txtFiltroVencIni"Name="vencto_ini"PropertyName="Text"Type="DateTime"/>
<asp:ControlParameterControlID="txtFiltroVencFim"Name="vencto_fim"PropertyName="Text"Type="DateTime"/>
...
</SelectParameters>
The stored procedure doesn't even execute, due to the bad formatted arguments. It returns the error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near '2005'.
I'm going to change the parameter type to varchar, as a workaround, but I'd like to solve this problem.
Thanks in advance,
Anderson
That is not it's normal behavior. Just for laughs, set the pages culture and uiculture to "en-US", and run the page again and see if the problem disappears. If it does, then it's a bug with your particular culture settings.Tuesday, March 6, 2012
.net cf class library commenting problem.
Hi All,
Now I am creating .Net CF2.0 class library project, and I have some public method which take parameters. And I commented those method using following tag.
/// <summary>
///
/// </summary>
/// <returns></returns>
But when I add to other project where I wanted use that dll , when I create instance andcall the method it’s not giving me the description which I gave. But when I refer in the same class library project itself it’s giving outside that it’s not giving the details.
Could you please anyone to solve this problem ?
Thanks ,
Jayakumar a
Hey when you compile the DLL with the above source, compile using /doc switch of CSC.EXE which then generates an XML file.
Place this XML file in the same direction as DLL which you have referenced so that you can see intellisense. Hope this helps!
By the way, this is not the right forum for your question. Please post this type of questions to VS IDE Forums so that you get better answers!
Thanks,
Laxmi
.Net 2.0 and datetime
Hi,
Here's my problem.
So using a stored proc and some parameters I want to update a datetime field
So I define @.theDate as datetime in my stored proc
in my vb.net app I have
dbcmd.Parameters.AddWithValue("@.theDate", SelectedDate)
where SelectedDate is
Dim SelectedDate as Nullable(of Datetime)
Now if SelectDate is a value all is good with the world.
However if SelectDate is Null I get an error.
How do I pass a null date to the stored proc ?
You need to add code like this:
dbcmd.Parameters.AddWithValue("@.theDate", (SelectedDate==null) ? DbNull.Value : SelectedDate)
DbNull.Value is a null for the database.
Sunday, February 19, 2012
*Passing parameters to an SP*
I need to embed Reports into an aspx page.
So I need to send parameters to the Report from the UI (aspx page).
I can do this using parameterized reports but I want to pass the parameters from the aspx page and not the report body .
Can anyone suggest how to do that.
Moreover in my application I have a Data Access Layer which is to be used to call the SPs. We dont call the SP directly. Then this Data Access layer returns the dataset.
Is it possible to integrate Reporting Services in such an architecture. I want this layer to get values from the Database otherwise I see calling the SP directly as the only option.
Thanks in advance
--
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.In Brian Larson's book there is an example of how to use aspx pages to call
RS. (Chapter 12)
http://www.osborne.com/products/0072232161/0072232161_code.zip
Regards,
Cem
"SqlJunkies User" <User@.-NOSPAM-SqlJunkies.com> wrote in message
news:eFyl4etWEHA.3476@.tk2msftngp13.phx.gbl...
> Hi
> I need to embed Reports into an aspx page.
> So I need to send parameters to the Report from the UI (aspx page).
> I can do this using parameterized reports but I want to pass the
parameters from the aspx page and not the report body .
> Can anyone suggest how to do that.
> Moreover in my application I have a Data Access Layer which is to be used
to call the SPs. We dont call the SP directly. Then this Data Access layer
returns the dataset.
> Is it possible to integrate Reporting Services in such an architecture. I
want this layer to get values from the Database otherwise I see calling the
SP directly as the only option.
> Thanks in advance
>
> --
> Posted using Wimdows.net NntpNews Component -
> Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine
supports Post Alerts, Ratings, and Searching.|||Cem Demircioglu wrote:
> In Brian Larson's book there is an example of how to use aspx pages
> to call RS. (Chapter 12)
> http://www.osborne.com/products/0072232161/0072232161_code.zip
> Regards,
> Cem
IMHO the sample code in ReportFrontEnd.aspx.vb has a minor error. In my
experience the call to
HttpContext.Current.Response.End()
within a try-catch block will _always_ end up in an exception of the kind
"the thread has been interrupted" or so.
Instead of coding
...
' Send the byte array containing the report as a binary response.
HttpContext.Current.Response.BinaryWrite(report)
HttpContext.Current.Response.End()
Catch ex As Exception
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "text/html"
HttpContext.Current.Response.Write("&
Error"
& ex.Message & "
")
HttpContext.Current.Response.End()
End Try
one should use
' Send the byte array containing the report as a binary response.
HttpContext.Current.Response.BinaryWrite(report)
Catch ex As Exception
HttpContext.Current.Response.ClearHeaders()
HttpContext.Current.Response.ClearContent()
HttpContext.Current.Response.ContentType = "text/html"
HttpContext.Current.Response.Write("<HTML><BODY><H1>Error</H1><br><br>"
& ex.Message & "</BODY></HTML>")
End Try
HttpContext.Current.Response.End()
... means keep the HttpContext.Current.Response.End() out of a try-catch
block.
roland
*Newbie* Evaluation of SP Parameters ....
if it's right or not?
This afternoon I've completely tied myself up trying to work out the
sequence in which parameters to a stored proc are evaluated, and could
really use someone to point out the obvious.
Basically I need to quickly retrieve a record based on 2 integer values
(foreign keys) and a string value. If my thinking is correct (') then the
SP will evaluate the first integer value, then the second, before trying to
evaluate the string. If I'm wrong, then the SP will try to evaluate all 3
simultaneously, and I know how slow evaluating a string can be.
The table the SP is querying is going to get pretty large (1 million records
+) and I'm AND'ing the parameters together in the WHERE clause for the SP.
I guess the question fundamentally is, am I OK doing the work in a single
SP, or should I first narrow the scope of the query EXEC'ing another SP
which uses the quick integer values, with the calling SP evaluating the
string value, albeit for a much smaller number of records?
Thanks for your time.
Andy"Andrew Kidd" <nospam@.nospam.com> wrote in message
news:%23CWa4D0oFHA.1996@.TK2MSFTNGP10.phx.gbl...
> You know when you stare at something for long enough, you start to
> question if it's right or not?
> This afternoon I've completely tied myself up trying to work out the
> sequence in which parameters to a stored proc are evaluated, and could
> really use someone to point out the obvious.
> Basically I need to quickly retrieve a record based on 2 integer values
> (foreign keys) and a string value. If my thinking is correct (') then the
> SP will evaluate the first integer value, then the second, before trying
> to evaluate the string. If I'm wrong, then the SP will try to evaluate all
> 3 simultaneously, and I know how slow evaluating a string can be.
> The table the SP is querying is going to get pretty large (1 million
> records +) and I'm AND'ing the parameters together in the WHERE clause for
> the SP.
> I guess the question fundamentally is, am I OK doing the work in a single
> SP, or should I first narrow the scope of the query EXEC'ing another SP
> which uses the quick integer values, with the calling SP evaluating the
> string value, albeit for a much smaller number of records?
> Thanks for your time.
> Andy
>
Some DDL and the sproc in question would be very helpful. I'm not entirely
sure what you are asking for...
A guess:
CREATE PROC dbo.Foo
@.fk1 int,
@.fk2 int,
@.val varchar(100)
AS
BEGIN
SET NOCOUNT ON
IF (SELECT COUNT(*) FROM SomeTable WHERE @.fk1 = SomeTable.FK1 AND @.fk2 =
SomeTable.FK2) > 0
BEGIN
-- Evaluate your string
END
ELSE
BEGIN
RETURN -- No match found.
END
END|||TSQL does not guarantee an evaluation order of conditionals like the C
languages do. But it is very smart - it will narrow the number of records it
must search as much as possible, so don't try to do its work for it.
"Andrew Kidd" wrote:
> You know when you stare at something for long enough, you start to questio
n
> if it's right or not?
> This afternoon I've completely tied myself up trying to work out the
> sequence in which parameters to a stored proc are evaluated, and could
> really use someone to point out the obvious.
> Basically I need to quickly retrieve a record based on 2 integer values
> (foreign keys) and a string value. If my thinking is correct (') then the
> SP will evaluate the first integer value, then the second, before trying t
o
> evaluate the string. If I'm wrong, then the SP will try to evaluate all 3
> simultaneously, and I know how slow evaluating a string can be.
> The table the SP is querying is going to get pretty large (1 million recor
ds
> +) and I'm AND'ing the parameters together in the WHERE clause for the SP.
> I guess the question fundamentally is, am I OK doing the work in a single
> SP, or should I first narrow the scope of the query EXEC'ing another SP
> which uses the quick integer values, with the calling SP evaluating the
> string value, albeit for a much smaller number of records?
> Thanks for your time.
> Andy
>
>|||"Rick Sawtell" <r_sawtell@.hotmail.com> wrote in message
news:e8mSdK0oFHA.3916@.TK2MSFTNGP12.phx.gbl...
> "Andrew Kidd" <nospam@.nospam.com> wrote in message
> news:%23CWa4D0oFHA.1996@.TK2MSFTNGP10.phx.gbl...
> Some DDL and the sproc in question would be very helpful. I'm not
> entirely sure what you are asking for...
> A guess:
> CREATE PROC dbo.Foo
> @.fk1 int,
> @.fk2 int,
> @.val varchar(100)
> AS
> BEGIN
> SET NOCOUNT ON
> IF (SELECT COUNT(*) FROM SomeTable WHERE @.fk1 = SomeTable.FK1 AND @.fk2
> = SomeTable.FK2) > 0
> BEGIN
> -- Evaluate your string
> END
> ELSE
> BEGIN
> RETURN -- No match found.
> END
> END
>
Yeah, sorry about not sticking in the SP, but to modify your example:
CREATE PROC dbo.Foo
@.fk1 int,
@.fk2 int,
@.val varchar(100)
AS
BEGIN
SET NOCOUNT ON
SELECT
SomeTable.PK
FROM
SomeTable
WHERE
SomeTable.FK1 = @.fk1
AND SomeTable.FK2 = @.fk2
AND SomeTable.SomeString = @.val
RETURN @.@.Rowcount
Hope this is more illustrative.|||I was hoping that this was the case, just looking for confirmation :-)
"KH" <KH@.discussions.microsoft.com> wrote in message
news:DE01A461-DFEA-4B8A-9EA7-85E72106A217@.microsoft.com...
> TSQL does not guarantee an evaluation order of conditionals like the C
> languages do. But it is very smart - it will narrow the number of records
> it
> must search as much as possible, so don't try to do its work for it.
>
> "Andrew Kidd" wrote:
>