Showing posts with label code. Show all posts
Showing posts with label code. Show all posts

Thursday, March 22, 2012

Asynchronus Transformation Component

Hi all,

I am missing something simple. I have added a new Transformation Script, put in my code to read the input rows, defined my outputs. I have tried to change the SynchonousInputId to 0, but I only get the option of None or input "Input 0" (91). What have I missed?

Set the SynchonousInputId to None.

The SynchonousInputId of "None" is synonymous with zero (0). The script transformation editor dropdown for the SynchonousInputId changed between service packs between saying "0" in the earlier case, to "None" in subsequent service packs. Both 0 and "None" for the SynchonousInputId property mean, "this is a async script transform".

Tuesday, March 20, 2012

Association Prediction by Rules Still Returns Itemsets

If I use this code with an association model, it still returns itemsets for me - when it should be returning only nodes with rules associated with them (according to sqlserverdatamining.com). If I try adding 'AND $PROBABILITY > .25' to the where clause, it returns 0 results for every query I try. Any clue why this may be happening?

Code Snippet

SELECT FLATTENED
(SELECT * FROM PredictAssociation([Product],20,
INCLUDE_NODE_ID,INCLUDE_STATISTICS)
WHERE $NODEID<>'')
FROM
[ProductRecommend]
PREDICTION JOIN
OPENQUERY([ds],
'SELECT
[PRODUCTCLASSID],[DESCRIPTION]
FROM
[Product_Table]
WHERE
[PRODUCTCLASSID] = ''1234'' AND [DESCRIPTION] = ''DESC''
') AS t

ON
[ProductRecommend].[Product].[PRODUCTCLASSID] = t.[PRODUCTCLASSID] AND
[ProductRecommend].[Product].[DESCRIPTION] = t.[DESCRIPTION]

This query returns more relevant results than those lacking the filtering by $NODEID, however the results should have higher probabilities than .047! Please help! Thanks!

Okay, I just reconstructed the same query using my data in a relational mining model (instead of OLAP) and got reasonable results. Would anyone know how to fix this for OLAP or be able to point me in a direction where I could go to learn how to do it? Thanks.

|||What is the MINIMUM_PROBABILITY value for the OLAP mining model?
Is it different than the one from the relational model?

One more thing (which you probably know already) -- the query you posted initially executes one prediction (PredictAssociation ... 20) for each row in the data source query (does not group together multiple input rows belonging to the same transaction).
Basically, only rules having a single item on the left hand side will be used in prediction.

Sunday, March 11, 2012

Assigning the results of a table function to a table variable

SQL Server 2K SP1.
I'm trying to put the results of a Table function into a Table variable for
use in a Select. My code is:
DECLARE @.LoanTable table (LoanNo DECIMAL(10,0), PRIMARY KEY (LoanNo))
SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
SELECT LoanNo
FROM UV_Tran016 AS t16
INNER JOIN @.LoanTable lt
ON t16.LoanNo = lt.LoanNo
The error I get is:
Server: Msg 195, Level 15, State 10, Line 4
'UDF_GetLoansInDeal' is not a recognized function name.
Line 4 is the SET statement.
SELECT TOP 10 *
FROM UDF_GetLoansInDeal (1, 8)
works just fine.
The function is defined as:
CREATE FUNCTION UDF_GetLoansInDeal
(
@.DealType int
, @.Id int
)
RETURNS @.LoansTable table
(
LoanNo DECIMAL(10,0)
)
AS
BEGIN
IF @.DealType = 1
BEGIN
INSERT @.LoansTable
SELECT Loan_No
FROM U_PledgeData
WHERE PledgeId = @.Id
ORDER BY PledgeId
END
ELSE
IF @.DealType = 2
BEGIN
INSERT @.LoansTable
SELECT Loan_No
FROM U_IntercompanyData
WHERE IntercompanyId = @.Id
ORDER BY IntercompanyId
END
RETURN
END
What am I doing wrong?
Thanks!I'm not positive, and obviously this is untested, but I think you just meant
to do this:
SELECT t16.LoanNo
FROM UV_Tran016 AS t16
INNER JOIN dbo.UDF_GetLoansInDeal(1,8) lt
ON t16.LoanNo = lt.LoanNo
"Bob" <notrainsley@.worldsavings.com> wrote in message
news:DD09EA8C-6F54-4086-BAF7-4DD2CC42879F@.microsoft.com...
> SQL Server 2K SP1.
> I'm trying to put the results of a Table function into a Table variable
> for
> use in a Select. My code is:
> DECLARE @.LoanTable table (LoanNo DECIMAL(10,0), PRIMARY KEY (LoanNo))
> SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
> SELECT LoanNo
> FROM UV_Tran016 AS t16
> INNER JOIN @.LoanTable lt
> ON t16.LoanNo = lt.LoanNo
> The error I get is:
> Server: Msg 195, Level 15, State 10, Line 4
> 'UDF_GetLoansInDeal' is not a recognized function name.
> Line 4 is the SET statement.
> SELECT TOP 10 *
> FROM UDF_GetLoansInDeal (1, 8)
> works just fine.
> The function is defined as:
> CREATE FUNCTION UDF_GetLoansInDeal
> (
> @.DealType int
> , @.Id int
> )
> RETURNS @.LoansTable table
> (
> LoanNo DECIMAL(10,0)
> )
> AS
> BEGIN
> IF @.DealType = 1
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_PledgeData
> WHERE PledgeId = @.Id
> ORDER BY PledgeId
> END
> ELSE
> IF @.DealType = 2
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_IntercompanyData
> WHERE IntercompanyId = @.Id
> ORDER BY IntercompanyId
> END
> RETURN
> END
> What am I doing wrong?
> Thanks!
>|||SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
should be
INSERT INTO @.LoanTable
SELECT * FROM dbo.UDF_GetLoansInDeal (1, 8)
Keith Kratochvil
"Bob" <notrainsley@.worldsavings.com> wrote in message
news:DD09EA8C-6F54-4086-BAF7-4DD2CC42879F@.microsoft.com...
> SQL Server 2K SP1.
> I'm trying to put the results of a Table function into a Table variable
> for
> use in a Select. My code is:
> DECLARE @.LoanTable table (LoanNo DECIMAL(10,0), PRIMARY KEY (LoanNo))
> SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
> SELECT LoanNo
> FROM UV_Tran016 AS t16
> INNER JOIN @.LoanTable lt
> ON t16.LoanNo = lt.LoanNo
> The error I get is:
> Server: Msg 195, Level 15, State 10, Line 4
> 'UDF_GetLoansInDeal' is not a recognized function name.
> Line 4 is the SET statement.
> SELECT TOP 10 *
> FROM UDF_GetLoansInDeal (1, 8)
> works just fine.
> The function is defined as:
> CREATE FUNCTION UDF_GetLoansInDeal
> (
> @.DealType int
> , @.Id int
> )
> RETURNS @.LoansTable table
> (
> LoanNo DECIMAL(10,0)
> )
> AS
> BEGIN
> IF @.DealType = 1
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_PledgeData
> WHERE PledgeId = @.Id
> ORDER BY PledgeId
> END
> ELSE
> IF @.DealType = 2
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_IntercompanyData
> WHERE IntercompanyId = @.Id
> ORDER BY IntercompanyId
> END
> RETURN
> END
> What am I doing wrong?
> Thanks!
>|||Aaron,
Ah, I see. Since the function returns a table, I can use the function in the
place of a table name in the join.
That makes sense, but I wanted to assign the table to a table variable
because I'm really going to do a delete on multiple tables and didn't want t
o
execute the function on each delete. For example,
DELETE UV_Tran016 AS t16
INNER JOIN dbo.UDF_GetLoansInDeal(1,8) lt
ON t16.LoanNo = lt.LoanNo
DELETE UV_Tran022 AS t22
INNER JOIN dbo.UDF_GetLoansInDeal(1,8) lt
ON t22.LoanNo = lt.LoanNo
DELETE UV_Tran025 AS t25
INNER JOIN dbo.UDF_GetLoansInDeal(1,8) lt
ON t25.LoanNo = lt.LoanNo
etc.
I believe the next reply shows me how to do that.
Thanks for the help,
Bob
"Aaron Bertrand [SQL Server MVP]" wrote:

> I'm not positive, and obviously this is untested, but I think you just mea
nt
> to do this:
> SELECT t16.LoanNo
> FROM UV_Tran016 AS t16
> INNER JOIN dbo.UDF_GetLoansInDeal(1,8) lt
> ON t16.LoanNo = lt.LoanNo|||Keith,
Ah, this is another place where SET is not used to assign a value to a local
variable. I get it.
Thanks,
Bob
"Keith Kratochvil" wrote:

> SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
> should be
> INSERT INTO @.LoanTable
> SELECT * FROM dbo.UDF_GetLoansInDeal (1, 8)
> --
> Keith Kratochvil|||"Bob" <notrainsley@.worldsavings.com> wrote in message
news:DD09EA8C-6F54-4086-BAF7-4DD2CC42879F@.microsoft.com...
> SQL Server 2K SP1.
> I'm trying to put the results of a Table function into a Table variable
> for
> use in a Select. My code is:
> DECLARE @.LoanTable table (LoanNo DECIMAL(10,0), PRIMARY KEY (LoanNo))
> SET @.LoanTable = UDF_GetLoansInDeal (1, 8)
> SELECT LoanNo
> FROM UV_Tran016 AS t16
> INNER JOIN @.LoanTable lt
> ON t16.LoanNo = lt.LoanNo
> The error I get is:
> Server: Msg 195, Level 15, State 10, Line 4
> 'UDF_GetLoansInDeal' is not a recognized function name.
> Line 4 is the SET statement.
> SELECT TOP 10 *
> FROM UDF_GetLoansInDeal (1, 8)
> works just fine.
> The function is defined as:
> CREATE FUNCTION UDF_GetLoansInDeal
> (
> @.DealType int
> , @.Id int
> )
> RETURNS @.LoansTable table
> (
> LoanNo DECIMAL(10,0)
> )
> AS
> BEGIN
> IF @.DealType = 1
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_PledgeData
> WHERE PledgeId = @.Id
> ORDER BY PledgeId
> END
> ELSE
> IF @.DealType = 2
> BEGIN
> INSERT @.LoansTable
> SELECT Loan_No
> FROM U_IntercompanyData
> WHERE IntercompanyId = @.Id
> ORDER BY IntercompanyId
> END
> RETURN
> END
> What am I doing wrong?
> Thanks!
>
The result of a table-valued function is a result set. It can't be assigned
directly to a variable. Replace the SET with an INSERT:
INSERT INTO @.LoanTable (LoanNo)
SELECT LoanNo FROM UDF_GetLoansInDeal (1, 8);
Another change you should make is to remove the ORDER BYs in your function.
They do nothing except maybe slow down the query.
Usually it's better to use in-line table-valued functions in preference to
multi-statement ones where you can. For example your function could be
rewritten as follows, which may yield a better query plan and faster
results.
CREATE FUNCTION UDF_GetLoansInDeal
(
@.DealType int
, @.Id int
)
RETURNS TABLE
AS
RETURN
(
SELECT Loan_No AS LoanNo
FROM U_PledgeData
WHERE PledgeId = @.Id
AND @.DealType = 1
UNION ALL
SELECT Loan_No AS LoanNo
FROM U_IntercompanyData
WHERE IntercompanyId = @.Id
AND @.DealType = 2
)
GO
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx

Thursday, March 8, 2012

Assign XML to variable

How do I assign XmlDocument results to a variable (so that I can pass it to a sp)?

I know that the following code works....

select * from tblUsers where userId = 1225 for XML raw

It returns "<row UserId="1225" LastName="Evans" FirstName="Stephanie" MiddleInitial=...."), which is what I want. But when I try to assign it, I get an error "Incorrect syntax near 'XML'."

declare @.strXml nvarchar(1000)

set @.strXml = (select * from tblUsers where userId = 1225 for XML raw)

Ideas?

It is not possible to do this in SQL Server 2000 using TSQL. You cannot consume the XML output on the server-side in any form. This is possible in SQL Server 2005 since there is a native XML data type and there are lot of improvements to FOR XML clause.

Assign session variable value to update parameter

Hi, I'm trying to update a sqlserver database through vb.net in an asp.net 2.0 project. I'm using a sqldatasource and am trying to code an update parameter with a session variable.

code snippet:

<UpdateParameters><asp:ParameterName="hrs_credited"/>

<asp:ParameterName="updater_id"DefaultValue="<%$ Session("User_ID")%>"Type="Int32"/>

<asp:ParameterName="activity_id"/>

<asp:ParameterName="attendee_id"/>

</UpdateParameters>

The error message that I receive is:

Error 2 Literal content ('<asp:Parameter Name="updater_id" DefaultValue="" Type="Int32"/>') is not allowed within a 'System.Web.UI.WebControls.ParameterCollection'. C:\Development\CME\dataentry\attendance.aspx 29

Does anyone have an idea how to assign the session var value to the parameter?

Thanks!

There is a special parameter called a SessionParameter that does exactly that. Refer to this page for more information:http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.sessionparameter.aspx

Wednesday, March 7, 2012

Assign expression value using code

I am trying to use a variable to set an attribute value of an SSIS task but I keep running into the 4000 character limit of the string variable. Not sure why the variable which is of .NET type String has this limit when it doesn't when you are in a .NET environment. Regardless, can anyone provide some sample code that I could use to do this in a script task? I am trying to set the QueryString property of the Data Mining Query Task. All help would be appreciated.

Thank you in advance.

Variables and expressions in SSIS are limited to 4000 bytes. Sorry.|||As far as dynamically setting the QueryString, when you look at the properties of the Data Mining Query task, is there an "expressions" parameter? If you expand the expressions parameter, do you have an option for QueryString? (I'm not sitting in front of SSIS at the moment, so I can't verify.) If so, you may want to put your variable there instead of using a script.|||

All task properties support expressions, it is only Data Flow components that require the developer to actually set some code that says an expression is supported.

The problem is that the result of an expression cannot be greater than 4000 characters. Using a variable whose value is greater than 4000 characters will not work because this still has to pass through the expression evaluator to be assigned to the property value.

Since the DM Query Task does not offer anything other than a literal string for the query, this cannot be set dynamically within the package. I think this is a limitation, obviously it would be nice to have expressions with > 4000 characters but also tasks should be (consistently) developed with properties such as this accepting literals, variables and files. An ideal example is the Execute SQL Task with the SourceSQLType property that describes the interpretation of the SQL Statement property.

|||That is too bad. Hopefully this will change in a later version. Thanks for the help.

assign count value

Hi all,

How I can assign a COUNT result to a variable in store procedure like this:

Code Snippet

SELECT @.NumCalc=COUNT(*) AS NC
FROM (SELECT COUNT(*) AS N
FROM Trace
GROUP BY Ora) TraceTmp

thanks a lot

by hid

Hi all sorry but

SELECT @.NumCalc=COUNT(*) /*AS NC */
FROM (SELECT COUNT(*) AS N
FROM Trace
GROUP BY Ora) TraceTmp

Run !

Bye Bye Hid

|||

If you want save into @.NumCalc result of SELECT COUNT(*) AS N FROM Trace GROUP BY Ora, you could use following code:

Code Snippet

SELECT @.NumCalc= COUNT(*)

FROM #Trace

GROUP BY Ora

But if SELECT COUNT(*) AS N FROM Trace GROUP BY Ora returns more than one line, only last result will be saved in @.NumCalc.

If you want save into @.NumCalc number of lines returned by SELECT COUNT(*) AS N FROM Trace GROUP BY Ora, you could use following:

Code Snippet

select @.NumCalc = count(distinct ora) from #trace

|||

Are you getting an error message returned? There's actually nothing wrong with your query - as long as you declare @.NumCalc then it should work fine.

Incidentally, your query is equivalent to this:

SELECT @.NumCalc = COUNT(DISTINCT Ora)

FROM Trace

...which, personally, I find easier to read.


Chris

|||

You code will not execute BECAUSE you cannot BOTH assign a aggregrate to a variable AND give it an ALIAS.

@.NumCalc=COUNT(*) AS NC

Remove the [ AS NC ] and it will execute just fine.

However, it would be easier to read if written as:


Code Snippet


SELECT @.NumCalc = count(DISTINCT Ora)
FROM Trace

|||

Arnie,

I see that this solution have been recommended several times. It will work just if column [Ora] does not accept NULL.

Code Snippet

select

count(distinct c1)

from

(

select null as c1

union all

select 1

) as t

select

count(*)

from

(

select

count(*) as cnt

from

(

select null as c1

union all

select 1

) as t1

group by

c1

) as t2

AMB

|||

'Hunchback'

I guess I didn't get your point. The OP asked for help with [ SELECT count(*) ]. In giving him/her the 'benefit of the doubt', I assume that if NULL is not to be included in the count, the OP will later clarify.

And yes, you are correct, there were previous variations of the same suggestion. I was not offering anything new EXCEPT for an explanition about why the OP's code excerpt would not work. (Actually, one post told the OP that there was "nothing wrong with your query", when in fact, it just will not execute as presented.

|||

Arnie,

> I assume that if NULL is not to be included in the count, the OP will later clarify.

The OP is counting the number of rows produced by a grouping by [Ora], so changing it to count(distinct [Ora]) could not produce the same result y [Ora] allows NULL. That was my point and was reproduced with the attached script.

AMB

|||Thanks for the clarification -I overlooked that point. I appreciate that you corrected my mistake.|||

Arnie said:

'Actually, one post told the OP that there was "nothing wrong with your query", when in fact, it just will not execute as presented.'

Yes, that was me. It seems that the OP had found a solution and subsequently corrected their query in a follow-up post, to which I was replying. The second query has the alias commented out so it will work as posted and, therefore, my statement is correct.

Chris

|||

Yes, I agree. Yet, it did seem confusing since due to forum latency it first appeared to me that you were responding to the original post. Even after the thread caught up, it was difficult to determine which post you responded to.

I should not have included that comment -it didn't add any value to the discussion. My regrets.

Assign a variable based upon query results...how to do it?

I have the following code which is incomplete. Where it says:
txtVendorID =
I need it to equal the results of the field VendorID from my query...here is my code. What do I need to add there?

Dim cmdSelectAs SqlCommand
Dim intRecordID
intRecordID = Request.QueryString("RecordID")
strConn = ConfigurationManager.AppSettings("conn")
conn =New SqlConnection(strConn)
cmdSelect =New SqlCommand("spMfgRepListAddaspxByRecordID", conn)
cmdSelect.CommandType = CommandType.StoredProcedure
cmdSelect.Parameters.AddWithValue("@.RecordID", intRecordID)
conn.Open()cmdSelect.ExecuteReader()
txtVendorID.Text =
conn.Close()If VendorID is the only field coming back from your SP (ie SELECT VendorID FROM...) then you can do

txtVendorID.Text = cmdSelect.ExecuteScalar().ToString(); // Might have a problem with NULL's if the SP returns no results so guard against this

Otherwise you have to use

SqlDataReader dr = cmdSelect.ExecuteReader();

if ( dr.Read() )
txtVendorID.Text = dr["VendorID"].ToString(); // Assumes VendorID is the name of your field|||

hi.

you need to use datareader as;

Dim

readerAs SqlDataReader

reader = cmd.ExecuteReader()

reader.Reade()

txtVendorID.Text =reader(

"VendorID").ToString() ' VendorID which retrive from the database.

Saturday, February 25, 2012

Assert Permission - Please Look into It

Hi All,
We are trying to find the solution for this for a very long time, hope I
can get solution for this thread.
This dll code is used to decryt the CreditCardNumber, This is working when
I use it in a web application, But I need to know what assert Permission I
need to Give to get the reult...
using System;
using System.Text;
using System.Net;
using System.IO;
using System.Collections.Specialized;
using System.Configuration;
using System.Security.Permissions;
using System.Security.Cryptography;
using FCLX509 = System.Security.Cryptography.X509Certificates;
using WSEX509 = Microsoft.Web.Services2.Security.X509;
using WSECRY = Microsoft.Web.Services2.Security.Cryptography;
namespace CreditCardDecrypt
{
/// <summary>
/// Summary description for DecryptClass.
/// </summary>
///
public class DecryptClass
{
public DecryptClass()
{
//
// TODO: Add constructor logic here
//
}
public static string DecryptCardInfo(string cc,string subjectName,string
storeName)
{
string sCreditCard = "";
try
{
WSEX509.X509CertificateStore.StoreLocation location = WSEX509.X509CertificateStore.StoreLocation.CurrentUser;
WSEX509.X509CertificateStore.StoreProvider provider = WSEX509.X509CertificateStore.StoreProvider.System;
WSEX509.X509CertificateStore store = new WSEX509.X509CertificateStore
(provider, location, storeName);
bool fopen = store.OpenRead();
if(fopen)
{
WSEX509.X509CertificateCollection certs = store.FindCertificateBySubjectString(subjectName);
if (certs.Count > 0)
{
WSEX509.X509Certificate cer = certs[0];
WSECRY.RSACryptoServiceProvider rsaCsp = (WSECRY.RSACryptoServiceProvider)cer.Key;
byte[] cipherData = Convert.FromBase64String(cc);
byte[] plainData = rsaCsp.Decrypt(cipherData, false);
sCreditCard = Encoding.UTF8.GetString(plainData);
}
}
if (store != null)
store.Close();
return sCreditCard;
//return cc;
}
catch(Exception ex)
{
return ex.ToString();
}
}
}
}
--
Message posted via http://www.sqlmonster.comWhat's the exception you get when you run the code.
It should tell you which permission needs to be asserted.
Or you can assert full trust which is less favorable due to security
reasons:
[PermissionSet(SecurityAction.Demand, Name="FullTrust")]
"BALAJI via SQLMonster.com" <forum@.nospam.SQLMonster.com> wrote in message
news:e70202f5043c49539b30bf614b8a6377@.SQLMonster.com...
> Hi All,
> We are trying to find the solution for this for a very long time, hope I
> can get solution for this thread.
> This dll code is used to decryt the CreditCardNumber, This is working when
> I use it in a web application, But I need to know what assert Permission I
> need to Give to get the reult...
> using System;
> using System.Text;
> using System.Net;
> using System.IO;
> using System.Collections.Specialized;
> using System.Configuration;
> using System.Security.Permissions;
> using System.Security.Cryptography;
> using FCLX509 = System.Security.Cryptography.X509Certificates;
> using WSEX509 = Microsoft.Web.Services2.Security.X509;
> using WSECRY = Microsoft.Web.Services2.Security.Cryptography;
> namespace CreditCardDecrypt
> {
> /// <summary>
> /// Summary description for DecryptClass.
> /// </summary>
> ///
> public class DecryptClass
> {
> public DecryptClass()
> {
> //
> // TODO: Add constructor logic here
> //
> }
> public static string DecryptCardInfo(string cc,string subjectName,string
> storeName)
> {
> string sCreditCard = "";
> try
> {
> WSEX509.X509CertificateStore.StoreLocation location => WSEX509.X509CertificateStore.StoreLocation.CurrentUser;
> WSEX509.X509CertificateStore.StoreProvider provider => WSEX509.X509CertificateStore.StoreProvider.System;
> WSEX509.X509CertificateStore store = new WSEX509.X509CertificateStore
> (provider, location, storeName);
> bool fopen = store.OpenRead();
> if(fopen)
> {
> WSEX509.X509CertificateCollection certs => store.FindCertificateBySubjectString(subjectName);
> if (certs.Count > 0)
> {
> WSEX509.X509Certificate cer = certs[0];
> WSECRY.RSACryptoServiceProvider rsaCsp => (WSECRY.RSACryptoServiceProvider)cer.Key;
> byte[] cipherData = Convert.FromBase64String(cc);
> byte[] plainData = rsaCsp.Decrypt(cipherData, false);
> sCreditCard = Encoding.UTF8.GetString(plainData);
> }
> }
> if (store != null)
> store.Close();
> return sCreditCard;
> //return cc;
> }
> catch(Exception ex)
> {
> return ex.ToString();
> }
> }
> }
> }
> --
> Message posted via http://www.sqlmonster.com

Assembly: returning "Globals!ReportName" but letting RS see it as code, not text?

I'm trying to make a reusable header function. In it, there is the report name and a couple other bits of info. The problem is making RS use the real report name

If I return "Globals!ReportName" in an assembly function, then call that function, I get that exact text - but what I really want is the report name. I understand what it's doing, but how to I trick it:

Is there some way to make RS aware of the fact that this is meant to be seen as something it needs to evaluate rather than just displaying the actual text?

How about passing the report name to your function as a parameter and then return the name in the return value?|||

that might be an option.

It's very similar to what i have in place - just appending the report name to the return value.

|||You probably tried this, but would it work to set a variable = Globals!ReportName.Value and then concatenate the variable with your other strings?
|||If you mean in the .net assembly, I just tried it and no luck, but thanks. It seems any text returned is taken to be literal, not code. I even tried something like {Globals!ReportName} - hoping to get lucky, but didn't.

Assembly MyAssembly was not found in the SQL catalog of database MyDB

I’m trying to register my CLR UDF in SQL 2005 using this code

CREATE FUNCTION GetSomething() RETURNS INT

AS EXTERNAL NAME MyAssembly.MyFunction.MyMethod

When I run it against my DB I get this error:

Assembly MyAssembly was not found in the SQL catalog of database MyDB

I’ve successfully registered my custom assembly in the DB (I see it under Assemblies folder), and I’ve set CRL Enabled to 1 in my DB.

What am I doing wrong?

Thanks in advance

A couple of things:

1. make sure that the CREATE FUNCTION call is actually executed in the database where MyAssembly is located.
2. Make sure that you spell the name correctly of the assembly

if both of those are OK:
1. then check that you do not have any namespaces in the class name. For example, VB injects a namespace into the assembly, so the class name would be [namespace.classname].
2. make sure that the classname and method name are capitalize correctly - they are case sensitive.

Niels

|||I have same problem and I do deployment using Visual Studio .NET 2005 final release, it is as nightmare to see these outstanding bug free products ...

Assembly MyAssembly was not found in the SQL catalog of database MyDB

I’m trying to register my CLR UDF in SQL 2005 using this code

CREATE FUNCTION GetSomething() RETURNS INT

AS EXTERNAL NAME MyAssembly.MyFunction.MyMethod

When I run it against my DB I get this error:

Assembly MyAssembly was not found in the SQL catalog of database MyDB

I’ve successfully registered my custom assembly in the DB (I see it under Assemblies folder), and I’ve set CRL Enabled to 1 in my DB.

What am I doing wrong?

Thanks in advance

A couple of things:

1. make sure that the CREATE FUNCTION call is actually executed in the database where MyAssembly is located.
2. Make sure that you spell the name correctly of the assembly

if both of those are OK:
1. then check that you do not have any namespaces in the class name. For example, VB injects a namespace into the assembly, so the class name would be [namespace.classname].
2. make sure that the classname and method name are capitalize correctly - they are case sensitive.

Niels

|||I have same problem and I do deployment using Visual Studio .NET 2005 final release, it is as nightmare to see these outstanding bug free products ...

aspx vb sql parameter passing

Hello,
Can someone kindly point out what is wrong with the following code file. I'm trying to:
- fill a dropdown from a db on page load (this works!)
- when user selects from the list and hits a button, pass the dropdown value to a second query
- use the second query to make another call to the db and fill a data grid

In the code below, if I swap an actual value (eg '1005') into the command and comment out the .Parameter.Add statements, the dategrid is filled sucessfully. Otherwise, when the button is pressed, nothing is displayed.

Thanks

PS comments about my coding approach are welcome - I'm new to aspx...


<%@. Language="VBScript" Debug="true"%>
<%@. Import Namespace="System.Data" %>
<%@. Import Namespace="System.data.SqlClient" %>
<html>
<head>
<script language="vb" runat="server">
Dim dbConnection As SqlConnection
Dim ds_Teams,ds_Agents As DataSet
Dim sqlCmd_Teams,sqlCmd_Agents As SqlDataAdapter

Dim dbConn = "server=csacd01;uid=mpierce;pwd=cabledog;database=clearviewacd"

Dim sql_select_teams = "" & _
"SELECT team_no, team_name " & _
"FROM dbo.team " & _
"WHERE (team_status = 'Curr')"

Dim sql_select_agents = "" & _
"SELECT last_name + ', ' + first_name AS name, agent_no " & _
"FROM dbo.users " & _
"WHERE (team_no = @.Team) AND (NOT (agent_no = '1029')) " & _
" AND (NOT (last_name IS NULL)) " & _
" AND (NOT (first_name IS NULL)) " & _
" AND (NOT (first_name = 'FirstName')) " & _
"ORDER BY last_name"

Dim teamList = "teamList"
Dim agentList = "agentList"

Sub Page_Load(Sender As Object, E As EventArgs)
if not (IsPostBack)
ds_Teams = new DataSet()
dbConnection = New SqlConnection(dbConn)
sqlCmd_Teams = New SqlDataAdapter(sql_select_teams, dbConnection)
sqlCmd_Teams.Fill(ds_Teams, teamList)
dbConnection.close()

dropdownlist_Teams.DataSource=ds_Teams.Tables(teamList).DefaultView
dropdownlist_Teams.DataBind()
end if
End Sub

sub Get_Agents(Sender As Object, E As EventArgs)
ds_Agents = new DataSet()
dbConnection = New SqlConnection(dbConn)
sqlCmd_Agents = new SqlDataAdapter(sql_select_agents, dbConnection)

sqlCmd_Agents.SelectCommand.Parameters.Add(new SqlParameter("@.Team", SqlDbType.NVarChar,4))
sqlCmd_Agents.SelectCommand.Parameters("@.Team").Value = dropdownlist_Teams.DataValueField

sqlCmd_Agents.Fill(ds_Agents,agentList)

dbConnection.close()

datagrid_Agents.DataSource=ds_Agents.Tables(agentList).DefaultView
datagrid_Agents.DataBind()
end sub

</script>
</head>
<body>
<form runat="server">
<asp:DropDownList id="dropdownlist_Teams" runat="server"
DataTextField="team_name"
DataValueField="team_no">
</asp:DropDownList
<input type="submit" onserverclick="Get_Agents" value="Get Agents" runat="server"><br /
<ASP:DataGrid id="datagrid_Agents" runat="server"
Width="500"
BackColor="#ccccff"
BorderColor="black"
ShowFooter="false"
CellPadding=3
CellSpacing="0"
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="false"
/>
</form>
</body>
</html>

(1) dim a variable as string and then assign the sql stmt to the variable.
xample :
dim str1 as string
str1="Select..."

(2) is the valuefield numeric or string type ? also you might want to move the assigning of the str stmt to the get_events event itself rather than declaring it as a global string.

hth

Thursday, February 16, 2012

ASP.NET,Gettting Error in the Program

Hi,

please have look into the code and let me know the solution plz.

string

ProID;try

{

using(SqlConnection conn=new SqlConnection(source))

{

conn.Open();

DataSet ds=

new DataSet();

DDLProject.Items.Clear();

SqlCommand cmd=

new SqlCommand("SP_ProjectSelect",conn);

cmd.CommandType=CommandType.StoredProcedure;

cmd.Parameters.Add("Name",SqlDbType.NChar,30,"@.Name");

cmd.UpdatedRowSource=UpdateRowSource.None;

cmd.Parameters["Name"].Value=DDLProductLine.SelectedItem;

SqlDataReader dr=cmd.ExecuteReader(); ---->>>> Here iam getting Following Error.

while(dr.Read())

{ Response.Write(dr["ID"].ToString());

}

}

}

catch(System.Exception ex)

{

Response.Write(ex);

}

Error:

System.InvalidCastException: Object must implement IConvertible. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteReader() at MIS.UI.ResourceList.DDLProductLine_SelectedIndexChanged(Object sender, EventArgs e) in c:\inetpub\wwwroot\dotnet pgms\mis\ui\resourcelist.aspx.cs:line 121

Any suggestion plzz,where went wrong.

Thanks in advance

Regards

Mahesh Reddy

Is it possible your stored procedure "SP_ProjectSelect" is not returning a result set? That's what it sounds like.|||

I think your oder in parameter.add was not correct.

The order should be SQL parameter, DataType, and Input Value.

In your case, it looks like

cmd.Parameters.Add("@.Name",SqlDbType.NChar,30,Name);

Here, "@.Name" is SQL parameter name, Name is the valueable you want to input. You can use "Name" for test. In this case, you will insert "Name" into table.

Also, NChar is not the good datatype for string name. I suggest you change it to VarChar (You need change it in SQL SP too).

Hope it helps

ASP.Net Unleashed Listing 12.16 Example

I am trying to get the following code to work but I keep getting an error.

DELETE statement conflicted with COLUMN REFERENCE constraint 'FK__titleauth__title__060DEAE8'. The conflict occurred in database 'pubs', table 'titleauthor', column 'title_id'.

Has anyone else experienced a problem with this example? Let me know what is wrong
with it.

Thanks,
Ralph


<%@. Page Language="VB" Debug="true" %>
<%@. import Namespace="System.Data" %>
<%@. import Namespace="System.Data.SqlClient" %>
<script runat="server"
Sub Page_Load
Dim dstPubs As DataSet
Dim conPubs As SqlConnection
Dim dadTitles As SqlDataAdapter
Dim dtblTitles As DataTable
Dim drowTitle As DataRow
Dim objCommandBuilder As New SqlCommandBuilder

' Grab Titles Table
dstPubs = New DataSet()
conPubs = New SqlConnection( "Server='(local)';Database=Pubs;trusted_connection=true" )
dadTitles = New SqlDataAdapter( "Select * from Titles", conPubs )
dadTitles.Fill( dstPubs, "Titles" )
dtblTitles = dstPubs.Tables( "Titles" )

' Display Original Titles Table
dgrdOriginalTitles.DataSource = dstPubs
dgrdOriginalTitles.DataBind()

' Add a Row
drowTitle = dtblTitles.NewRow()
drowTitle( "Title_id" ) = "xxxx"
drowTitle( "Title" ) = "ASP.NET Unleashed"
drowTitle( "Price" ) = 1200.00
drowTitle( "Type" ) = "Mystery"
drowTitle( "PubDate" ) = #12/25/1966#
dtblTitles.Rows.Add( drowTitle )

' Delete the First Row
dtblTitles.Rows( 0 ).Delete()

' Double the price of the Second Row
drowTitle = dtblTitles.Rows( 2 )
drowTitle( "Price" ) *= 2

' Generate the SQL Commands
objCommandBuilder = New SqlCommandBuilder( dadTitles )

' Update Titles Table
dadTitles.Update( dstPubs, "Titles" )

' Display New Titles Table
dgrdNewTitles.DataSource = dstPubs
dgrdNewTitles.DataBind()
End Sub

</script>
<html>
<head>
<title>UpdateDataSet</title>
</head>
<body>
<h2>Original Titles Table
</h2>
<asp:DataGrid id="dgrdOriginalTitles" Runat="Server"></asp:DataGrid>
<h2>New Titles Table
</h2>
<asp:DataGrid id="dgrdNewTitles" Runat="Server"></asp:DataGrid>
</body>
</html>

change this line

dgrdOriginalTitles.DataSource = dstPubs

to this

dgrdOriginalTitles.DataSource = dtblTitles

see if that works|||Thanks for the suggestion. I tried something else...I remarked out the following code and then it worked fine.

Thanks,
RT


' Update Titles Table
dadTitles.Update( dstPubs, "Titles" )

Monday, February 13, 2012

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

SQLExpress database file auto-creation error:

The connection string specifies a local SQL Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

SQLExpress database file auto-creation error:

The connection string specifies a local SQL Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

SQLExpress database file auto-creation error:

The connection string specifies a local SQL Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...|||

Hi bass_player,

I think I was a bit late in getting this error, but when I got it in 2007 your post of 2005 saved my day.

Thanks a lot

RaghavS

|||hi
the first three steps done greatly
the fourth is not
i did not find any<connectionStrings> in my web.config

i'm just a beginer
thank u
|||

Place the <connectionstrings>...</connectionstrings> section right before the <system.web> seciton

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

SQLExpress database file auto-creation error:

The connection string specifies a local SQL Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...|||

Hi bass_player,

I think I was a bit late in getting this error, but when I got it in 2007 your post of 2005 saved my day.

Thanks a lot

RaghavS

|||hi
the first three steps done greatly
the fourth is not
i did not find any <connectionStrings> in my web.config

i'm just a beginer
thank u
|||

Place the <connectionstrings>...</connectionstrings> section right before the <system.web> seciton

Asp.Net not finding the SQLServer for setting up Security problem

I have just reciently installed and started upgrading the last beta code to this beta and am having a problem conecting to my sqlinstance with the WebSite Configuration Tool.

The error indicates it is looking for a file in the app_data directory. (empty), but everthing else points to SQLServer (express) as being the issue.

I have run aspnet_regsql.exe (both on my default instance of sql (a sql2kas) and the beta2 instance that shipped with VS.

Both created datasases and eveyting looked good inside the db's.

However when I click the "Securtiy tab" I get a message "Unable to connect to SQL Server Database."

When I go to The Provider Tab, there is nothing to configure, just a test Hlink that generates the following when clicked.

SQLExpress database file auto-creation error:

The connection string specifies a local SQL Server Express instance using a database location within the applications App_Data directory. The provider attempted to automatically create the application services database because the provider determined that the database does not exist. The .......

I have run SQL Trace (profiler) against both instances of SQL when aps is trying to connect, but neither show anything.

I keep feeling like I must have missed something.. Anyu clues are welcome.

Rob

The issue was the Machine.Config file and the fact that when I named my new instance of SQL2005, I installed it using a NonDefault name.

This I fixed by editing the Machine.Config file and changing the Connection String for the Database Access. (Can't remember just which one, but if you do a search for SQLExpress in teh machine.config you will find it.)

HTH

Rob
Smile|||Here is another approach in using a full blown SQL Server as the repository of your credentials for ASP.NET 2.0 if you do not want to use the default SQL Express.

1) Create a database in SQL Server (2000 or 2005) and make sure that you give the ASPNET account permissions to this database.
2) Run the aspnet_regsql.exe file in your System%Root\Microsoft.NET\Framework\v2.0.xyz directory. This will open an ASP.NET SQL Server Setup Wizard which will create the objects necessary for ASP.NET security.
3) Point to the database you just created.
4) In your web.config file, locate the <connectionStrings> element and add the following:

<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost;initial catalog=<your database name>;integrated security=true" providerName="System.Data.SqlClient">

This overrides the default SQL Express and points to the new database you just created - be it in the same machine or a different machine. You can also change the configuration in the machine.config file although this will affect every web application sitting on top of your machine.|||WOW! it did solve my problem. thanks so much|||

Worked !

Thanks a lot.

(I can now start growing my hair back )

Bill

|||

I have the same problem :S

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

i still get error

Error 4 XML document cannot contain multiple root level elements.

:S:S


|||

<connectionStrings>

<remove name="LocalSqlServer" />

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;

integrated security=true " providerName="System.Data.SqlClient">

</connectionStrings>

I think your error might be pointing to the Add tag as it is missing the Close Tag. However you seem to have an XML issue, not the issue that started the thread..

Rob

E.G. (highlighted in red)

<add name ="LocalSqlServer" connectionString="Data Source=localhost;initial catalog = memberDB;integrated security=true " providerName="System.Data.SqlClient" />

|||Is it mandatory to have SQL Server for accessing the security features like creating users and roles in ASP.Net Configuration tool? If not please tell me the way to avoid the same problem...|||

Hi bass_player,

I think I was a bit late in getting this error, but when I got it in 2007 your post of 2005 saved my day.

Thanks a lot

RaghavS

|||hi
the first three steps done greatly
the fourth is not
i did not find any <connectionStrings> in my web.config

i'm just a beginer
thank u
|||

Place the <connectionstrings>...</connectionstrings> section right before the <system.web> seciton