Showing posts with label app. Show all posts
Showing posts with label app. Show all posts

Thursday, March 22, 2012

Default ASPNETDB database

Hi

I want to set up my web app to use a web parts personalization, I notice that a default database named aspnetdb is made, I also made one in my sql server using the aspnet_regsql.exe to make it. Now what I need to find out is how to make my app point to the database in the sql server instead of making that default one.

Thanks

You need to modify your connectionstring in the web.config to point to the instance of the DB you wish to connect to.

Marco

Please mark as answered if this helps!

|||

Hi

thanks for the response, how exactly should I use the connection string and where in the file?

thanks

|||

Hello - are you using VWD? Your web.config file will be stored where all your .aspx files are stored. Open the file and make the below changes (in bold)

<connectionStrings>

<addname="DatabaseNameHere"connectionString="Data Source=ComputerNameHere\SQLInstanceNameHere;Initial Catalog=DatabaseNameHere;Integrated Security=True"providerName="System.Data.SqlClient"/>

</connectionStrings>

Marco

|||

Hi, thanks for the string, the connection works but the app still uses that local aspnetbd as the default database, any ideas as to why.

thanks

|||

Hello - try adding a customized membership provider in your web.config, which if implemented as below is just a copy of the default provider but with a different name, Then point the customized membership provider to your connection string. Read this article which fully explains what your are trying to do -http://aspnet.4guysfromrolla.com/articles/120705-1.aspx

<membershipdefaultProvider="CustomizedMembershipProvider">

<providers>

<addname="CustomizedMembershipProvider"type="System.Web.Security.SqlMembershipProvider"connectionStringName="XXXXXXXX"applicationName="XXXXXXXXXX"/>

</providers>

</membership>

|||

Thanks that put me in the right path now im getting a error on the connection string

ERROR :The specified connectionStringName, 'xxxx', was not registered.

Any ideas,

Thanks

|||

Hello - have you replaced the 'xxxx' with the name of your connection string? the name of your connection string is in your web.config

<connectionStrings>

<addname="XXXXX" - this is where the name of your connection string will be.

Marco

|||

Hi, thanks for all your help again, that set me on the right path and I found the solution.

What I found out is that the machine.config file was looking for a connection named LocalSqlServer so in order to override that I had to clear that connection, I was using the <remove> element to remove the LocalSqlServer but didn't seem to work, so I just used the <clear/>, also I named the new connection LocalSqlServer because without it it was giving me a "connectionstring not register" error, so as soon as I named it LocalSqlServer it went through. I'm not sure if it can go in with a different name as every time I tried to name it differently it gave me errors, it was looking for LocalSqlServer regardless. I also had to give the Aspnet user access to that database.

Here is a sample of what I used

<connectionStrings
<clear/>
<add name="LocalSqlServer" connectionString="Data Source=path/;database=aspnetdb;Integrated Security=True" providerName="System.Data.SqlClient" /
</connectionStrings
<system.web
<roleManager enabled="true" />
<compilation debug="true" strict="false" explicit="true"/
<authentication mode="Forms" /
<webParts>
<personalization defaultProvider="AspNetSqlPersonalizationProvider">
<providers
<clear/>
<add connectionStringName="LocalSqlServer"
name="AspNetSqlPersonalizationProvider" type="System.Web.UI.WebControls.WebParts.SqlPersonalizationProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="/appname" /
</providers>
</personalization>
</webParts
</system.web
</configuration>

Maybe this might help someone else.

Thanks agian for your help

Friday, March 9, 2012

Decimal value is getting rounded

I am writing a simple shopping cart app and the price field is being rounded when inserted into the database.
There is a textbox for the user to enter the price. A stored procedure is used to insert the line item info to the data base table. The field in the table is formatted as datatype decimal. Below is the stored procedure and the code that adds the value to the parameter. Any suggestions on where I am going wrong?
<Code>
CREATE PROCEDURE [sp_insert_CartDetail]
(
@.ReferenceNum [int],
@.Item [varchar](26),
@.Desc1 [varchar](27),
@.Desc2 [varchar](20),
@.Desc3 [varchar](30),
@.Desc4 [varchar](30),
@.Note [text],
@.Quantity [int],
@.DateOrdered [datetime],
@.SalesPrice [decimal],
@.DistCost [decimal],
@.SalesTaxable [smallint],
@.RequiredDate [datetime],
@.User1 [varchar](12),
@.User2 [varchar](12),
@.User3 [varchar](12),
@.User4 [varchar](12),
@.User5 [varchar](12),
@.User6 [varchar](12))

AS INSERT INTO [ToolCrib].[dbo].[CartDetail]
(
[ReferenceNum],
[Item],
[Desc1],
[Desc2],
[Desc3],
[Desc4],
[Note],
[Quantity],
[DateOrdered],
[SalesPrice],
[DistCost],
[SalesTaxable],
[RequiredDate],
[User1],
[User2],
[User3],
[User4],
[User5],
[User6])

VALUES
(
@.ReferenceNum,
@.Item,
@.Desc1,
@.Desc2,
@.Desc3,
@.Desc4,
@.Note,
@.Quantity,
@.DateOrdered,
@.SalesPrice,
@.DistCost,
@.SalesTaxable,
@.RequiredDate,
@.User1,
@.User2,
@.User3,
@.User4,
@.User5,
@.User6)
SqlCmdInsetCartDetail.Parameters("@.SalesPrice").Value =CType(txtCost.Text,Decimal)

</code>

Does the table field have precision and scale set for the decimal type? You'd want to set them also for decimal type parameters.|||db table has precision of 18 and scale of 0. What should it be set to if I want decimal to 4 places. Is decimal the correct data type for this situation?
Thanks,
Danny|||Try this link for code to set the precision and scale in .NET. Hope this helps.
http://support.microsoft.com/?kbid=892406|||I have set the scale to 4 on both the data table and the parameters... No change
Caddre, I don't think that pertains to my situation. 1 - I am running this on MSSQL7. 2-I am not returning a value from the sproc.
|||In SQL Server 7.0 change the data type to Numeric it is more stable in SQL Server 7.0 than Decimal because I remember when Money was rounding to less than one dollar in 1999 the only fix was with Numeric. And set the precision and scale, why I think it comes from TDS(tabular data stream) 7.0. Hope this helps.

Saturday, February 25, 2012

Debugging?

Hi,
Is there a way to debug an SQL Server stored procedure? I call a number of sp's from my .net app and need a way to step through them.
Thank you,http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vxtskasqldebuggingexample.asp
|||Thanks. Your link also pointed to the following link:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/html/vchowapplicationdebugging.asp
that shows, supposedly, how to debug a stored procedure inline with your app. This is what I'm looking for, because I need to be able to see what the stored procedure is receiving in it's parameters. I followed the steps in the link above, put a breakpoing in the stored procedure and another one in my app just before the stored procedure, and, contrary to the claims of the article, I was not able to step into the procedure. Any help getting this to work would be appreciated!
Thanks.|||Is the SQL Server on your local machine? If not you have toinstall the remote debugging components. This article tells youhow to install and configure remote debugging (as well as various othercool debugging tips):
http://www.dbazine.com/sql/sql-articles/cook1
|||It is on my local machine.

Tuesday, February 14, 2012

debug (step into) sql stored proc from managed code

I am trying to debug sql2000 sp from managed code app with VS.Net 2003 archetect Ed..
It did not stop at the break point within the sql sp.
I did granted execute permission for sp_sdidebug.
Do I need to attach any process?

Is there anything left off by the article?
I referenced msdn article option 2: http://support.microsoft.com/default.aspx?kbid=316549

Thanks.Please use the word "bump" or something such as, "Any help?" so that the moderators recognise the purpose of your single-character message. Otherwise, the message may be deemed meaningless, and will be deleted.|||Sorry, this is really a Visual Studio.NET question. I have no idea.

Terri