Showing posts with label primary. Show all posts
Showing posts with label primary. Show all posts

Friday, March 23, 2012

Failed to convert parameter value from a String to a Guid?

Hi all,

I have setup my database that have 3 columns:

1. Primary Key

2. UserId (UniqueIdentifier, Guid I guess) - I set it up so I can insert the value from the Membership table (UserId) for some relationship.

3. Another Foreign key with just an int.

I tried to build a DAL, ran a test and received this error: "Failed to convert parameter value from a String to a Guid." Before I setup my UserId to be UniqueIdentifier and let it be just an Int, I don't have any problem retrieving data. Here is the SELECT query that I built with the DataSet:

SELECT aspnet_Users.UserId, t_music.MUSIC_TITLE
FROM t_user_viewed
JOIN aspnet_Users ON aspnet_Users.UserId = t_user_viewed.UserId
JOIN t_music ON t_music.MUSIC_PK = t_user_viewed.MUSIC_PK_FK
WHERE aspnet_Users.UserId = @.UserId

Any help would be greatly appreciated,

Kenny.

You need to post definition for @.UserId parameter.

|||

Can you please elaborates? I'm new to asp.net as well as ms-sql.

Thank you,

Kenny.

|||

Sounds like you need to cast the string value to GUID on the @.UserId when you call the select function and pass the @.UserId value.

ctype(StringValueGUID, GUID)

Burl

|||

Where do I cast the string value? In the DAL (dataset) or where I have my ObjectDataSource doing the select? Sorry for my lack of knowledge on asp.net and mssql.

Thanks,

Kenny.

|||

How are you passing the GUID to the ObjectDataSource for the select? Wherever that value comes from, its in a string type and needs to be cast as a GUID type. Can you post some code?

Burl

|||

I've created a Dataset and setup my table, then I've created a BLL that have this code to get the fields:

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
public NotesNhac.t_user_viewedDataTable GetSongsByUserPK(Guid UserId)
{
return Adapter2.GetSongsByUserPK(UserId);
}

In my ObjectDataSource, I chose the above method (GetSongsByUserPK) and have the parameter source as a session. Here is the code for the ObjectDataSource:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSongsByUserPK"
TypeName="SongsBBL">
<SelectParameters>
<asp:SessionParameter Name="UserId" SessionField="UserId" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>

The SELECT query is the same as my first post... is there anything else I need to do?

Thank you very, very much.

Kenny.

|||

Well,

I've made some minor adjustment to my code and it's working now, however, the SELECT statement that I wrote in the DataSet didn't return the proper table. Here are the changes:

1. In my DataSet, I have setup the table called t_user_viewed that will store the primary key of t_music database as foreign key, and the UserId from the aspet_users as another foreign key. Here is the select statement:

SELECT *
FROM t_music a
JOIN t_user_viewed b on a.MUSIC_PK = b.MUSIC_PK_FK
JOIN aspnet_Users c ON b.UserID = c.UserId
WHERE b.UserID = @.UserId

So when I run this code, and enter the UserId, it should return the information from table "t_music" (with all information such as song title, artist, etc...) instead.

2. This is the code for the SongsBLL.cs class, to get the above select statement:

private t_user_viewedTableAdapter _t_user_viewed = null;

protected t_user_viewedTableAdapter Adapter2
{
get
{
if (_t_user_viewed == null)
_t_user_viewed = new t_user_viewedTableAdapter();

return _t_user_viewed;
}
}

[System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
public NotesNhac.t_user_viewedDataTable GetSongsByUserPK(Guid UserId)
{
return Adapter2.GetSongsByUserPK(UserId);
}

3. Here is the ObjectDataSource that was generated by VS:

<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetSongsByUserPK"
TypeName="SongsBBL" OldValuesParameterFormatString="original_{0}">
<SelectParameters>
<asp:SessionParameter Name="UserId" SessionField="UserId" Type="Object" />
</SelectParameters>
</asp:ObjectDataSource>

4. Here is the GridView that was generated automatically when I select the DataSourceID to the above ObjectDataSource:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="VIEWED_PK"
DataSourceID="ObjectDataSource1">
<Columns>
<asp:BoundField DataField="VIEWED_PK" HeaderText="VIEWED_PK" InsertVisible="False"
ReadOnly="True" SortExpression="VIEWED_PK" />
<asp:BoundField DataField="MUSIC_PK_FK" HeaderText="MUSIC_PK_FK" SortExpression="MUSIC_PK_FK" />
<asp:BoundField DataField="UserID" HeaderText="UserID" SortExpression="UserID" />
</Columns>
</asp:GridView>

Apparently, the GridView & the ObjectDataSource only pick up the t_music_viewed table columns, instead of the "t_music" columns that I specified in my Select statement.

Any idea?

Thank you very much,

Kenny.

|||

I've solved it by building my SELECT query in the "t_music" table instead.

THANK YOU!

Kenny.

|||

I've solved it by building my SELECT query in the "t_music" table instead.

THANK YOU!

Kenny.

sql

Monday, March 19, 2012

Failed Node Need to rebuild

I am having an issue with the primary node of our SQL 2005 x64 Cluster
(Windows2003EnterpriseEditionx64). After installing SP1 I am getting the
below error when the service tries to start.
So obviously I messed up something during the upgrade. So decided to write
this node off and try and reinstall SQL. Unfortunately it will not
uninstall because it can not see the quorum drive even though it really is
there. Obviously I can not move the group because the service is failed.
How can I for uninstall SQL to try and rebuild the node? Has anyone seen
this issue before? I would rather not rebuild the OS if possible. It is
only SQL that is failing the rest of the box it working great.
Event Type: Error
Event Source: Service Control Manager
Event Category: None
Event ID: 7024
Date: 11/22/2006
Time: 8:33:48 AM
User: N/A
Computer: SQL001A
Description:
The SQL Server (MSSQLSERVER) service terminated with service-specific error
17058 (0x42A2).
Hi Tim,
I ran into a similar issue when working on SQL 20056 clusters in my lab. I
did find a link that was very useful when trying to uninstall a node manually.
Take a look at this one and let me know if it helps;
http://msdn2.microsoft.com/en-US/library/ms180973.aspx
Regards,
Sporter
"Tim Murray" wrote:

> I am having an issue with the primary node of our SQL 2005 x64 Cluster
> (Windows2003EnterpriseEditionx64). After installing SP1 I am getting the
> below error when the service tries to start.
> So obviously I messed up something during the upgrade. So decided to write
> this node off and try and reinstall SQL. Unfortunately it will not
> uninstall because it can not see the quorum drive even though it really is
> there. Obviously I can not move the group because the service is failed.
> How can I for uninstall SQL to try and rebuild the node? Has anyone seen
> this issue before? I would rather not rebuild the OS if possible. It is
> only SQL that is failing the rest of the box it working great.
> Event Type: Error
> Event Source: Service Control Manager
> Event Category: None
> Event ID: 7024
> Date: 11/22/2006
> Time: 8:33:48 AM
> User: N/A
> Computer: SQL001A
> Description:
> The SQL Server (MSSQLSERVER) service terminated with service-specific error
> 17058 (0x42A2).
>
>

failed insert because of duplicate rows and still locks held by application

Hi,
we are using SQL Server 2005.
We have a problem because of an application which tries to
insert a duplicate row in a table with primary key. This insert fails
of course but the locks are not released within this transcation.

This is not locking up on MS SQL Server 2000. But we can see the lock is still applied there.

Can someone help me on this?

Thanks,

Hmmm. What locks are held by the INSERT? Is this a stored procedure you are calling?

Can you post the code you are calling? It sounds like you might be in a Serializable isolation level, perhaps, and an explicit transaction is being started but not cleared. Are you using connection pooling?

|||We are not using connection pooling. The application is written in 'C' langugage and we are using Standard ODBC drivers provided by Microsoft. There are no explicit locking done for this insert query. After failure if I commit or rollback the lock gets released. I can see locks are also held in MS SQL Server 2000 also but they are not blocking other users to accress that perticular table. I have not chnaged isolation level in both (MS SQL Server 2005 and MS SQL Server 2000). The same application also runs with Oracle 9i and on failure of insert statment dos not locking oracle table. I am trying to figure out what locking mechanisum is changed in MS SQL Server 2005. Do I need to change any default settings in MS SQL Server 2005 which will not lock the table on failure of insert because of duplicate rows.|||

Try looking at the output of this query:

select login_name,
case des.transaction_isolation_level
when 0 then 'Unspecified' when 1 then 'ReadUncomitted'
when 2 then 'ReadCommitted' when 3 then 'Repeatable'
when 4 then 'Serializable' when 5 then 'Snapshot'
end as transaction_isolation_level,
request_session_id, resource_type, resource_subtype, request_mode,

request_type, request_status, request_owner_type,
case when resource_type = 'object' then object_name(resource_associated_entity_id)
when resource_type = 'database' then db_name(resource_associated_entity_id)
when resource_type in ('key','page') then

(select object_name(object_id) from sys.partitions

where hobt_id = resource_associated_entity_id)
else cast(resource_associated_entity_id as varchar(20))
end
from sys.dm_tran_locks dtl
left outer join sys.dm_exec_sessions des
on dtl.request_session_id = des.session_id
where request_session_id <> @.@.spid

and this:

select der.session_id, der.wait_type, der.wait_time,
der.status as requestStatus,
des.login_name,
cast(db_name(der.database_id) as varchar(30)) as databaseName,
des.program_name,

der.command as commandType,

execText.text as objectText,
case when der.statement_end_offset = -1 then '--see objectText--'
else SUBSTRING(execText.text, der.statement_start_offset/2,
(der.statement_end_offset - der.statement_start_offset)/2)
end AS currentExecutingCommand,

der.open_transaction_count
from sys.dm_exec_sessions des
join sys.dm_exec_requests as der
on der.session_id = des.session_id
cross apply sys.dm_exec_sql_text(der.sql_handle) as execText
where des.session_id <> @.@.spid --eliminate the current connection

to see if you have a statement executing and

See what kinds of locks are being held and what the isolation level is. It is probably just not being disconnected and has a transaction open. Then try profiler to see exactly what is being sent. There is likely a setting that you need to set, but without seeing the code this is not easy to do.

|||

Thanks for reply.

The first query is giving follwing result:

Login Tran_Isolation re_ses resource_type mode type Status Owner Table

sasi ReadCommitted 56 PAGE IX LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 RID X LOCK GRANT TRANSACTION 72057594243186688
sasi ReadCommitted 56 PAGE IX LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 KEY X LOCK GRANT TRANSACTION ACLS6999
sasi ReadCommitted 56 OBJECT IX LOCK GRANT TRANSACTION ACLS6999

The second query is not returning any rows.

|||I think you are going to have to use profiler and trace the activity on your server for this process. Post the queries if you can and then we can see what might be wrong.

Monday, March 12, 2012

Failed during recovery

I have been having a lot of trouble trying to reattach a database. The
latest issue is that after 9% of recovery I get a primary key violation and
it stops.
Is there anything I can do to get around this'
Thanks
RichardWhat SQL Server version are you using?
If you are using 2000, have you installed service pack 4?
thanks,
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>|||You most likely dettached the database without using the checkpoint command
to commit the data on memory to disk. This caused your identities to become
of synch to fix run dbcc checkident( sysrestorehistory ) in the msdb
database.
do you still have the old database?
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>|||Richard
Do you have last FULL BACKUP of the database? If you do , perform just
RESTORE command
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>

Failed during recovery

I have been having a lot of trouble trying to reattach a database. The
latest issue is that after 9% of recovery I get a primary key violation and
it stops.
Is there anything I can do to get around this?
Thanks
Richard
What SQL Server version are you using?
If you are using 2000, have you installed service pack 4?
thanks,
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this?
> Thanks
> Richard
>
|||You most likely dettached the database without using the checkpoint command
to commit the data on memory to disk. This caused your identities to become
of synch to fix run dbcc checkident( sysrestorehistory ) in the msdb
database.
do you still have the old database?
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this?
> Thanks
> Richard
>
|||Richard
Do you have last FULL BACKUP of the database? If you do , perform just
RESTORE command
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this?
> Thanks
> Richard
>

Failed during recovery

I have been having a lot of trouble trying to reattach a database. The
latest issue is that after 9% of recovery I get a primary key violation and
it stops.
Is there anything I can do to get around this'
Thanks
RichardWhat SQL Server version are you using?
If you are using 2000, have you installed service pack 4?
thanks,
--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>|||You most likely dettached the database without using the checkpoint command
to commit the data on memory to disk. This caused your identities to become
of synch to fix run dbcc checkident( sysrestorehistory ) in the msdb
database.
do you still have the old database?
--
/*
Warren Brunk - MCITP - SQL 2005, MCDBA
www.techintsolutions.com
*/
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>|||Richard
Do you have last FULL BACKUP of the database? If you do , perform just
RESTORE command
"Richard Douglass" <RDouglass@.arisinc.com> wrote in message
news:uXV9FzS3GHA.4764@.TK2MSFTNGP02.phx.gbl...
>I have been having a lot of trouble trying to reattach a database. The
>latest issue is that after 9% of recovery I get a primary key violation and
>it stops.
> Is there anything I can do to get around this'
> Thanks
> Richard
>

Wednesday, March 7, 2012

Fact Table/Dimension and Multiple Level Dimension

Hi Guys,

I have two questions on Analysis Service for SQL SERVER 2005:-

a) Is it possible for me to use two tables from my database without Primary Key. As this use to work on my Analysis Service on SQL SERVER 2000.

b) I had a multiple Level Dimension in SQL SERVER 2000 with Key Column as one column in my table and name column as another in my table. I am not able to do the same in SQL SERVER 2005.

Urgent help is requried.

Regards,

Kaushal

a)You do not need primary keys in the source data base but I think you need to set logical primary keys in the data source view.

b)Key and name columns are still separated in Analysis Services 2005.

Regards

Thomas Ivarsson

|||

Hi Thomas,

Thanks for Reply.

a) Yes i do understand that, but then what happens if i want to use the columns used in Primary key as levels in a Dimension?

b) I am still not understanding how to take kare of Key and Name Columns?

Regards,

Kaushal

Fact Table Many-to-Many Relationship

Hi

I've just started using SSAS2005 in a health application.

My main Fact table is a Patient Details table with Patient ID as primary key. The cube built around it uses age and gender as dimensions, with median age and Male-Female ratio as some of the measures.

Now in the same Data Source View I've added a Treatment Fact table with multiple treatment rows per Patient ID, each row containing treatment details and the name of the hospital which provided the treatment.

How do I create a dimension or link between these two tables so that in the same cube I can summarize, by hospital, both the number of treatments (and other treatment-related measures and dimensions) as well as the characteristics (age/gender) of patients treated in each hospital? Sounds like a many-to-many relationship but I don't know how to implement it in this case.

Thanks in advance.

You could set up a Patient measure group with a PatientCount measure and a Treatment measure group with a TreatmentCount measure. Age and Gender dimensions are directly related to the Patient measure group, and Hospital to the Treatment measure group. If you then create a PatientDetails fact dimension for the Patient measure group, which is also directly related to the Treatment measure group, the Hospital dimension can have a Many-to-Many relation with the Patient measure group, via the PatientDetails intermediate dimension. You can refer to the Many-to-Many relation of SalesReason to Internet Sales in Adventure Works, for a similar example.|||

Thanks Deepak, that worked. Much appreciated.

fact or dimension table

Hi
How does one decide if data should go into a fact or dimension table?
I have 1 primary key and lots of textual information (5 fields) which
suggests dimension.
However, the data is extremely unlikely to change, which suggets fact'
AntNeither of these suggests "fact" vs. "dimension".
A fact is a record of something that occurred -- a sales transaction, for
instance, is a fact. A dimension is information that can be used to
identify the fact -- when it occurred, who was involved, etc.
Facts and dimensions are decided based on the logical context of the data,
not on the basis of when or how the data operates.
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"-ants-" <ants@.inurpants.com> wrote in message
news:T9udnVc4pNyZl8DZRVny1g@.pipex.net...
> Hi
> How does one decide if data should go into a fact or dimension table?
> I have 1 primary key and lots of textual information (5 fields) which
> suggests dimension.
> However, the data is extremely unlikely to change, which suggets fact'
>
> Ant
>|||"Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
news:us8kK6UcGHA.3344@.TK2MSFTNGP03.phx.gbl...
> Neither of these suggests "fact" vs. "dimension".
Hi
could we talk about this via private email please? Is your email address
valid?
Ant|||I would be happy to dicuss this with you privately, but please keep in mind
that I consider private help to be a type of consulting service, so we'll
have to work out contractual terms first. If you'd like to proceed with
that, you can e-mail me at the e-mail address I've used here, minus
"_removetoemail_".
Otherwise, we can keep discussing here in the public group.
Also, you might want to read this book, which someone recently posted a link
to here:
http://www.redbooks.ibm.com/abstrac...47138.html?Open
It is a free book from IBM on dimensional modeling. I flipped through it
and it seems like a great intro text (especially given its price!
Adam Machanic
Pro SQL Server 2005, available now
http://www.apress.com/book/bookDisplay.html?bID=457
--
"-ants-" <ants@.inurpants.com> wrote in message
news:jt2dnek5tKugk8DZRVnyvQ@.pipex.net...
> "Adam Machanic" <amachanic@.hotmail._removetoemail_.com> wrote in message
> news:us8kK6UcGHA.3344@.TK2MSFTNGP03.phx.gbl...
> Hi
> could we talk about this via private email please? Is your email address
> valid?
> Ant
>

Friday, February 24, 2012

Extracting the duplicates using Fuzzy Grouping

Hi,

I have an Oracle table called "Party" which contains Party_Id as primary key and have Party_Name, Party_Addr etc., as fields. We have lot more duplicate party details such as (party_name and party_addr) in this table. We are trying to aviod duplicates using FUZZY logic of SSIS.

1. Is any body suggest me how to create package to avoid duplicates using Fuzzy logic for this scenario(Step by step instructions are good for me to understand SSIS).

2. Could you please provide me some samples for FUZZY(Please send me a sample to my email)

Ever heard of Google? http://www.google.ie/search?hl=en&q=ssis+fuzzy&meta=

Emailing defeats the object of having online forums and it is far easier for people to reply here than to send an email. Perhaps you could do the legwork yourself instead of asking people to do it for you?

-Jamie