Need To Avoid Repeated Data In A DataGrid

Apr 15, 2004

Hi there :)





I am developing a system for my uni course and I am stuck a little problem...





Basically its all about lecturers, students modules etc - A student has many modules, a module has manu students, a lecturer has many modules and a module has many lecturers.





I am trying to get a list of lecturers that run modules associated with a particular student. I am able to get a list of the appropriate lecturers, but some lecturers are repeated because they teach more than one module that the student is associated with.





How can I stop the repeats?





Heres my sql select code in my cs file:





string sqlDisplayLec = "SELECT * FROM student_module sm, lecturer_module lm, users u WHERE sm.user_id=" + myUserid + "" + " AND lm.module_id = sm.module_id " + " AND u.user_id = lm.user_id ";


SqlCommand sqlc2 = new SqlCommand(sqlDisplayLec,sqlConnection);


sqlConnection.Open();


lecturersDG.DataSource = sqlc2.ExecuteReader(CommandBehavior.CloseConnection);


lecturersDG.DataBind();





And here is a pic of my Data Model:


Data Model Screenshot





Any ideas? Many thanks :) !

View 1 Replies


ADVERTISEMENT

Tsql - Avoid Repeated Rows

Sep 23, 2007

Hi Guys,


I am using the query below to retrieve these results:
You can see that the results are repeated, once for DATIF = 1 and then again for DATIF = 2.
In this case does not matter if the results appear close to DATIF 1 or DATIF 2.
Take in care that I can not know how may extradates or Extrasums are attached to each Account.

Is there any way to avoid these repeated rows?
Thanks in advance,
Aldo.


ACCOUNTKEY DATFID DATFNAME DATF SUFID SUFNAME SUF

--------------- ----------- -------------------------------------------------- ----------------------- ----------- -------------------------------------------------- ----------------------

123456 1 ExtraDates01 2005-01-01 00:00:00.000 1 ExtraSum01 4

123456 1 ExtraDates01 2005-01-01 00:00:00.000 2 ExtraSum02 3

123456 1 ExtraDates01 2005-01-01 00:00:00.000 3 ExtraSum03 1

123456 1 ExtraDates01 2005-01-01 00:00:00.000 4 ExtraSum04 2

123456 2 ExtraDates02 2004-01-01 00:00:00.000 1 ExtraSum01 4

123456 2 ExtraDates02 2004-01-01 00:00:00.000 2 ExtraSum02 3

123456 2 ExtraDates02 2004-01-01 00:00:00.000 3 ExtraSum03 1

123456 2 ExtraDates02 2004-01-01 00:00:00.000 4 ExtraSum04 2



Code Snippet
SELECT DISTINCT

Accounts.ACCOUNTKEY,

ExtraDates.DATFID,

ExtraDateNames.DATFNAME ,

ExtraDates.DATF ,

ExtraSums.SUFID ,

ExtraSumNames.SUFNAME ,

ExtraSums.SUF
FROM
EXTRADATES AS ExtraDates
LEFT OUTER JOIN EXTRADATENAMES AS ExtraDateNames ON ExtraDates.DATFID = ExtraDateNames.DATFID
RIGHT OUTER JOIN ACCOUNTS AS Accounts ON ExtraDates.KEF = Accounts.ACCOUNTKEY
LEFT OUTER JOIN EXTRASUMS AS ExtraSums
LEFT OUTER JOIN EXTRASUMNAMES AS ExtraSumNames ON ExtraSums.SUFID = ExtraSumNames.SUFID ON Accounts.ACCOUNTKEY = ExtraSums.KEF
LEFT OUTER JOIN EXTRANOTENAMES
RIGHT OUTER JOIN EXTRANOTES ON EXTRANOTENAMES.NOTEID = EXTRANOTES.NOTEID ON Accounts.ACCOUNTKEY = EXTRANOTES.KEF
WHERE
Accounts.SORTGROUP BETWEEN 0 AND 999999999
AND Accounts.ACCOUNTKEY BETWEEN '123456' AND '123456'

View 2 Replies View Related

Search Repeated Record And Give Suggestion As Most Repeated One

Sep 4, 2007

I have problem, i wanted a query which will search the duplicate and then give suggestionmost repeated word
Table containing the records like below








ID 
Movie Name 
New Name

1
Spider Man 
Spider Man

2
Spider Man 2 
Spider Man

3
Spider Man 3 
Spider Man

4
Spider Man UK 
Spider Man

5
Spider Man USA 
Spider Man

6
New Spider Man 
Spider Man

7
Spider Man Black 
Spider Man

8
Spider Man Part 1 
Spider Man

9
Spider Man Part 2 
Spider Man

10
Spider Man I 
Spider Man

11
Spider Man III 
Spider Man

12
Spider Man Part II 
Spider Man
My manufacturer send me the data in this format and i have to allocate there new name
to do some comparison
I wanted to make this process automatic.
what i mean is i need a query which will give me a repeated records  along with suggestion
as new name.
I am fully confident that you  guys will help me out from this problem.
Looking forward

View 9 Replies View Related

Repeated Data

Dec 21, 2004

If I have a student table with 3 columns ID, FirstName and LastName
ID- FirstName -LastName
-------------------------
1 Tom Hanks
2 Jerry Thomas

and I have a subject table with two columns StudentID and Subject. StudentID is a foreign key to the student table.
StudentID - Subject
------------------------
1 History
1 Biology
2 History

If my query is
select distinct student.id, student.fname, student.lname, student.subject from student
left outer join subject on student.id = subject.studentid

then I get
1 Tom Hanks History
1 Tom Hanks Biology.

Is there a way I could get
1 Tom Hanks History
null null null Biology

--> meaning I don't want to repeat data??

thanks
Teena

View 1 Replies View Related

Rows Repeated With Same Data

Dec 17, 2013

For the below mentioned query their is repetition of rows with the same data.

SELECT srs.prod_area as PA,
srs.art as ArtNo,
b.adsc_unicode as ArtName,
cast(case when a.unit <> '2' then c.avsx/10 else c.avsx/1000 end as integer(2)) as AwsMHS,
cast(srs.estimate/10 as integer(1)) as AwsSRSThisWeek,

[Code] ....

View 4 Replies View Related

Removing Rows With Repeated Data

Sep 7, 2005

I am running a query on multiple tables and the data I get back consists of several repeated rows but with one column different. I want to take out those repeated rows and for the column that is different join that data and separate it by a comma. Can this be done?

Ex.
Cindy Lair 111 Drury Circle Harrisburg Pennsylvania 717
Cindy Lair 111 Drury Circle Harrisburg Pennsylvania 610
Cindy Lair 111 Drury Circle Harrisburg Pennsylvania 310

So i would like this data to come up as:
Cindy Lair 111 Drury Circle Harrisburg Pennsylvania 717,610,310

View 7 Replies View Related

Matrix Show Repeated Data

Jan 12, 2007

Hi,

i have a matrix with some fixed columns. when the fixed columns have repeated data, the repeated data is hidden.

how do you show the data all the time??

eg. i have:

Customer - Month - bikes - balls - toys - Total

Sam - January - 0 - 4 - 10 - 14

- February - 3 - 2 - 8 - 13

- March - 2 - 0 - 9 - 11

Tom - January - 2 - 5 - 2 - 9

- February - 5 - 2 - 8 - 15

- March - 1 - 6 - 3 - 10

but i want it to show like this:

Customer - Month - bikes - balls - toys - Total
Sam - January - 0 - 4 - 10 - 14
Sam - February - 3 - 2 - 8 - 13
Sam - March - 2 - 0 - 9 - 11
Tom - January - 2 - 5 - 2 - 9
Tom - February - 5 - 2 - 8 - 15
Tom - March - 1 - 6 - 3 - 10

Thanks.

View 3 Replies View Related

Normalization - How To Get Repeated Data From Existing Table

Jul 8, 2014

What I need to know is how to get repeated data from a existing table, to normalized tables with out typing it...

Example:

---------------------
| ID |TEXT | TAGS |
---------------------
| 1 |text1|repeating|
| 2 |text2|repeating|
----------------------

How to normalization would be use 3 tables ,one for tags_id and tags, and another relating the tags_id to ID from the table above...but how does the code already know there is a tag called repeating?

View 3 Replies View Related

HELP!!! Creating Nested Data In Repeated Region Problem

Jul 28, 2007

Hi All, Would appreciate some assistance with the attached, I'm using some fairly complicated recordsets (ASP VBScript) for a property search website, I have a page where a user selects search by County this in turn takes them to a page which lists all the towns in the county and number of live properties in each, I'm using 4 recordsets for this - 3 of which list the towns (townsA2I, townsJ2R & townsS2Z) the 4th is a Property Count, examples of the recordsets are below (using townsAtoI and LiveProperties -

TownsA2I

<%
Dim TownA2I
Dim TownA2I_numRows

Set TownA2I = Server.CreateObject("ADODB.Recordset")
TownA2I.ActiveConnection = MM_recruta2_STRING
TownA2I.Source = "SELECT towncountyID, Town, County FROM dbo.easytolettowncounty WHERE Town LIKE 'A%' AND County = '" + Replace(TownA2I__MMColParam, "'", "''") + "' OR Town LIKE 'B%' AND County = '" + Replace(TownA2I__MMColParam1, "'", "''") + "' OR Town LIKE 'C%' AND County = '" + Replace(TownA2I__MMColParam2, "'", "''") + "' OR Town LIKE 'D%' AND County = '" + Replace(TownA2I__MMColParam3, "'", "''") + "' OR Town LIKE 'E%' AND County = '" + Replace(TownA2I__MMColParam4, "'", "''") + "' OR Town LIKE 'F%' AND County = '" + Replace(TownA2I__MMColParam5, "'", "''") + "' OR Town LIKE 'G%' AND County = '" + Replace(TownA2I__MMColParam6, "'", "''") + "' OR Town LIKE 'H%' AND County = '" + Replace(TownA2I__MMColParam7, "'", "''") + "' OR Town LIKE 'I%' AND County = '" + Replace(TownA2I__MMColParam8, "'", "''") + "' ORDER BY Town ASC"
TownA2I.CursorType = 0
TownA2I.CursorLocation = 2
TownA2I.LockType = 1
TownA2I.Open()

TownA2I_numRows = 0
%>

LiveProperties

<%
Dim LiveProperties
Dim LiveProperties_numRows

Sub sLivePropertyCount(vLocation)
vCount=0

Set LiveProperties = Server.CreateObject("ADODB.Recordset")
LiveProperties.ActiveConnection = MM_recruta2_STRING
LiveProperties.Source = "SELECT COUNT(PropertyID) As NumberofProperties, propertylive, propertylocation FROM dbo.easytoletproperty WHERE propertylive = 'y' AND propertylocation = " & vLocation & " GROUP BY propertylocation, propertylive"
LiveProperties.CursorType = 0
LiveProperties.CursorLocation = 2
LiveProperties.LockType = 1
LiveProperties.Open()

vCount=(LiveProperties("NumberofProperties"))
Response.write(vCount)

LiveProperties.Close()
Set LiveProperties = Nothing
end sub

LiveProperties_numRows = 0
%>

I've tried following the tutorial here http://www.webthang.co.uk/tuts/tuts_dmx/rob9/rob9.asp but when i review the page i get the following error -

"Microsoft OLE DB Provider for SQL Server error '80040e14'

Invalid column name 'Barnet'.

/PropertiesbyTown1.asp, line 338 "

Where line 338"

Where line 338 is the "LiveProperties.Open()" of the above recordset, when i try to view bindings on this recordset Dreamweaver gives me the following errors -

"Column 'dbo.easytoletproperty.propertylive' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause.

Column 'dbo.easytoletproperty.propertylocation' is invalid in the select list because it is not contained in an aggregate function and there is no GROUP BY clause."

I would appreciate any assistance -

View 1 Replies View Related

Comparing Similar Tables - Removing Duplicate Or Repeated Data

Sep 30, 2007

It seems that there should be a solution for my situation, but for the life of me I can't seem to figure it out.

I need to compare two "like" tables, containing similar data. Tbl 1 is "BOOKED" (which is a snapshot of inventory) and tbl 2 is "CURRENT" (the live - working inventory table). If I write my query as follows the the subsequent result is "duplicate" data.




Code Block
SELECT booked.item, booked.bin, booked.quantity, current.bin, current.quantity
FROM BOOKED
LEFT JOIN
CURRENT
ON booked.item = current.item







No matter what type of join I use, there is duplicate data displayed for each table. For example, if there are more bins in the BOOKED table that contain a certain product then the CURRENT table will repeat data and vica versa.

As follows:







Item
Bin
Quantity
Bin
Quantity

12345
A01
500
A01
7680

12345
B01
6
A01
7680

12345
C01
20
A01
7680

54321
G10
1032
E15
1163

54321
G10
1032
F20
523

54321
G10
1032
H30
750

98765
Z20
7000
Z20
8500

98765
Y15
2500
Y15
3000

98765
X10
1200
Y15
3000

What I would like to do is display Bin and Quantity only once and the repeating values as NULL or [BLANK]. Or, to display all of the bins from both tables and only the quantities from each table in relation to the bin found in that table, returning a "0" if no quantity exists.

This is what I'm after:







Item
Bin
Quantity
Bin
Quantity

12345
A01
500
A01
7680

12345
B01
6
B01
0

12345
C01
20
C01
0

54321
G10
1032
E15
1163

54321
F20
0
F20
523

54321
H30
0
H30
750

98765
Z20
7000
Z20
8500

98765
Y15
2500
Y15
3000

98765
X10
1200
X10
0



Is this possible? If so, how?

I also might add that it is ok for each table to contain multiple entries for any given item. This is basically being requested as an inventory variance report - inventory before physical count and immediatly after physical count - and will only be run once a year.

-----------------------------------------------
Just thinking out loud here:
What if I created three subqueries, the first containing only BOOKED information, the second containing only CURRENT information and the third being a UNION of both tables? Something like this:




Code Block
SELECT q3.bin, q1.item, ISNULL(q1.quantity, 0) as QTY_BEFORE, ISNULL(q2.quantity, 0) as QTY_AFTER

FROM

(select item, bin, quantity
from BOOKED)q1
Left Join

(select item, bin, quantity
from CURRENT)q2
on q1.item = q2.item
Left Join

(select bin, item
from BOOKED
UNION
CURRENT)q3
on q1.item = q3.item

Order By q1.item





I don't know if I wrote the UNION statement correctly, but I will have to try this when I get back to work...


Any suggestions?

View 7 Replies View Related

Any One Tell Me The Best Process To Bind The Data To Datagrid?

Jun 2, 2008

Hi,

Any one tell me the best process to bind the data to datagrid?I am using this method,it is taking lot of time to fill data to datagrid.

conn = new SqlCeConnection("Data Source=\sample.sdf; Password =''");
dt = new DataTable();
da = new SqlCeDataAdapter(Quary, conn);
da.Fill(dt);
DataaGrid1.Datasource=dt;

Any one tell the best method?

Regards,
venkat.

View 9 Replies View Related

Transfer Data From Datagrid To Tables In Sql Server

Jul 12, 2006

    Hello, I like to know how to transfer current data displayed in my datagrid into a table in sql server. Any help is much appreciated.Thanks!

View 1 Replies View Related

Displaying Data In Datagrid From A Normalized Set Of Tables

Jul 23, 2007

Ok, I'm fairly new to .NET and even newer to the whole database concept.  But, don't run away yet, I'm no idiot and I shouldn't have too hard of a time understanding your responses if you're kind of enough to give them.  That being said, here's my dilemma:I'm trying to make a database of all the movies I own, the actors in them and the genre (s) they belong to. I have a set of tables that are in the 2NF (I think).  I have a movies table, an actors table, a genres table, and two tables called movies_actors and movies_genres with primary-foreign key relationships to pull it all together (e.g. movie_id 1 has two entries in movies_genres, one for Action and one for Drama). My problem arises that when execute my monster query to pull ALL the data on one movie, I get a row returned for every combination of Genres and Actors in a movie.  Example:movie_id            movie_title            comments            actor_first         actor_last            genre_name1                        Casino                  blah blah            Robert               DeNiro               Action1                        Casino                  blah blah            Robert               DeNiro               Drama1                        Casino                  blah blah            Joe                  Pesci                  Action1                        Casino                  blah blah            Joe                  Pesci                  Drama And here's the query that produced that:1 SELECT movies.movie_title, movies.comments, actors.actor_first,
2 actors.actor_last, genres.genre_name
3 FROM movies INNER JOIN movies_actors ON movies.movie_id = movies_actors.movie_id
4 INNER JOIN actors ON movies_actors.actor_id = actors.actor_id
5 INNER JOIN movies_genres ON movies_genres.movie_id = movies.movie_id
6 INNER JOIN genres ON movies_genres.genre_id = genres.genre_id
So, I want to put all the actors for one movie into the same cell in the datagrid (same with the genres) and still keep it sortable by actor or genre.  Is this possible with the .NET 2.0 datagrid?  Do I have some fundamental misunderstanding of how my tables should be structured?  Am I just really far off and acting like a n00b?

View 9 Replies View Related

Display Data Using Mxdatagrid Or Datagrid In Webmatrix

Feb 24, 2004

what i'm trying to do is simply display the contents of the sqldata to verify that it works. and it doesn't. i have created a simple database named 'test' and table 'list' with fields: 'name' and 'id'. i have made 3 records as follows:

NAME ID
name1 1
name2 2
name3 3

what i did is connect to the database, click and drag it over to the canvas and codes were generated. if i run it, by default it should show all the contents of the table, correct? well, it isn't. i've tried it using a datagrid and it still doesn't work.

is there an access problem with the database? or, what settings to have to make/change in my sql server? by the way, i have MSDE.


<%@ Page Language="VB" %>
<%@ Register TagPrefix="wmx" Namespace="Microsoft.Matrix.Framework.Web.UI" Assembly="Microsoft.Matrix.Framework, Version=0.6.0.0, Culture=neutral, PublicKeyToken=6f763c9966660626" %>
<script runat="server">

' Insert page code here
'
Function test() As System.Data.IDataReader
Dim connectionString As String = "server='(local)'; trusted_connection=true; database='test'"
Dim dbConnection As System.Data.IDbConnection = New System.Data.SqlClient.SqlConnection(connectionString)

Dim queryString As String = "SELECT [list].* FROM [list]"
Dim dbCommand As System.Data.IDbCommand = New System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

dbConnection.Open
Dim dataReader As System.Data.IDataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection)

Return dataReader
End Function

</script>
<html>
<head>
</head>
<body>
<form runat="server">
<wmx:SqlDataSourceControl id="SqlDataSourceControl1" runat="server" DeleteCommand="" ConnectionString="server='(local)'; trusted_connection=true; database='Northwind'" SelectCommand="SELECT * FROM [Employees]" UpdateCommand=""></wmx:SqlDataSourceControl>
<wmx:MxDataGrid id="MxDataGrid1" runat="server" OnLoad="MxDataGrid1_Load" DataSource="<%# SqlDataSourceControl1 %>" BorderStyle="None" BorderWidth="1px" DataKeyField="EmployeeID" CellPadding="3" BackColor="White" AllowPaging="True" DataMember="Employees" AllowSorting="True" BorderColor="#CCCCCC" DataSourceControlID="SqlDataSourceControl1">
<PagerStyle horizontalalign="Center" forecolor="#000066" backcolor="White" mode="NumericPages"></PagerStyle>
<FooterStyle forecolor="#000066" backcolor="White"></FooterStyle>
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#669999"></SelectedItemStyle>
<ItemStyle forecolor="#000066"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#006699"></HeaderStyle>
</wmx:MxDataGrid>
<!-- Insert content here -->
</form>
</body>
</html>

View 4 Replies View Related

False Error When Trying To Return Data In Datagrid

Jul 23, 2005

VB.NET 2003 / SQLS2KThe Stored Procedure returns records within Query Analyzer.But when the Stored Procedure is called by ADO.NET ~ it produced thefollowing error message.---------------------------Exception Message: Failed to enable constraints. One or more rowscontain values violating non-null, unique, or foreign-key constraints.------------------------------------------------------Exception Source: System.Data---------------------------If I click OK past the error messages I will get data filling thedatagrid. However not as I would like to see it.Even though it returns the proper data rows and includes all thecolumns I asked for, it also returns plenty of columns I didn't ask for(all the columns of the main table) and all those columns are filledwith "null"In addition each row header contains a red exclaimation mark whch whenhovered over reads;"Column 'cmEditedBy' does not allow DBNull.Values."An interesting thing about this column 'cmEditedBy' is that there isnoting wrong with it and all rows for that column contain data.I believe this error is a mistake! But it probably indicates some otherproblem. How should I track its cause?M O R E ...Below is the code in the data layer, the stored procedure, and the datareturned within query analyzer.\'DataAdapterFriend daView041CmptCyln As New SqlDataAdapter'SqlCommandPrivate daView041CmptCyln_CmdSel As New SqlCommand'Add the commanddaView041CmptCyln.SelectCommand = daView041CmptCyln_CmdSel'SelectWith daView041CmptCyln_CmdSel.CommandType = CommandType.StoredProcedure.CommandText = "usp_View_041Cmpt_ByJobCyln".Connection = sqlConnWith daView041CmptCyln_CmdSel.Parameters.Add(New SqlParameter("@RETURN_VALUE", SqlDbType.Int, _4, ParameterDirection.ReturnValue, False, CType(0,Byte), _CType(0, Byte), "", DataRowVersion.Current, Nothing))'Criteria.Add("@fkJob", SqlDbType.Text).Value = _"48c64a55-874d-40d0-addc-7245f5d9c118"'.Add("@fkJob", SqlDbType.Text).Value = f050View.jobIDEnd WithEnd With//\ALTER PROCEDURE usp_View_041Cmpt_ByJobCyln(@fkJob char(36))AS SET NOCOUNT ON;SELECTJobNumber,DeviceName,ComponentName,Description,Quan,Bore,Stroke,Rod,Seconds,CylPSI,PosA,PosB,PosC,PosD,PosE,HomeIsRet,RetIsRetrac,POChecks,Regulated,FlowControl,PortSize,LoadMassFROM tbl040cmptINNER JOIN tbl030Devi ON fkDevice = pkDeviceIdINNER JOIN tbl020Proc ON fkProcess = pkProcessIdINNER JOIN tbl010Job ON fkJob = pkjobIdINNER JOIN lkp202ComponentType ON fkComponenttype = pkComponentTypeIdINNER JOIN lkp201DeviceType ON fkDeviceType = pkDeviceTypeIdINNER JOIN lkp101PortSize on cmSmallint05 = pkPortSizeIdWHERE(fkJob = @fkJob)--fkJob = '48c64a55-874d-40d0-addc-7245f5d9c118'AND fkComponentType = 2GO//(note - columns are wrapped)\F1111Clip DriverCylinderClip Driver_2 - Top -Cylinder91.2502.250.8752.250NULL01101110011/8 NPTNULLF1111Punch MechCylinderPunch Mech_1 -Cylinder_222.1002.0001.0001.234NULL11000110011/8NPTNULLF1111ClipDriverCylinderBottom92.1002.0001.0001.000NULL11010110011/4NPTNULLF1111Punch MechCylinderPunch Mech_1 -Cylinder_122.1002.0001.0001.000NULL01000110011/8NPTNULLF1111DegateCylinderDegate 1 -Cylinder21.1882.500.8751.000NULL11000110011/8 NPTNULLF1111Clip DriverCylinderClip Driver 1 -Bottom11.1801.250.8751.000NULL00011110011/4 NPTNULL//

View 1 Replies View Related

How To Pull Data Into A Datagrid From The Same Table, 2 Fields, And Display Them As 1 Field In The SqlDataSource?

Jan 9, 2008

Hi, Im trying to pull data from 2 fields in the same table into a SqlDataSource that feeds into a GridView, and display them as 1 field in GridView? I have a database table that has entries of users and their friends. so
this tblFriendUser has a column called UserName and another column
called FriendUserName.
I am trying to get a list of friends for that particular user. Note
that if User1 initiated the friend request, he will be listed as
UserName and his friend as FriendUserName, but if his friend initiated
the friend request, it will be vice versa: him being the FriendUserName
and his friend the UserName. So I want the following 2 queries run and merged into
one query in order to return 2 columns only: UserFriendID & UserName, is that
possible? Is my design bad? Any suggestions/advice would help! Thanks a lot!


SELECT UserFriendID, UserName
FROM tblUserFriends
WHERE (UserName = @UserName);

SELECT UserFriendID, FriendUserName AS UserName
FROM tblUserFriends
WHERE (FriendUserName= @UserName);

View 5 Replies View Related

SQL Server Compact Table Not Getting Data Edits Made In Datagrid From Vs05 C#

Mar 13, 2007

New to SQL Server Compact Edition and I am getting my feet wet with the following tutorial: http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060831MobileRB/manifest.xml

I follow the tutorial exactly, but the data I edit through the Edit Dialog Form is not saved to the SQL Server table even though all of the edits appear in the datagrid. They never make it back into the table.

Any help would be appreciated.

Thanks!





View 7 Replies View Related

How To Avoid For..each When There's No Data

Oct 25, 2007



Hi everyone,

As first task I've got Data Flow which loads a set of data into a .NET recordset.
After that, inmediately flow execution goes to For..Each Loop. I'd like to avoid go in that direction when Data Flow returns zero rows.

How can I do such thing?

I've tried this on Precedence Constraint Editor but it doesn't work..It doesn't recognize EOF keyword..

@[User::ResulSet] == EOF


Thanks in advance for your input,

Enric

View 3 Replies View Related

How To Avoid Duplicate Data

May 7, 2015

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sectionexpenses]
(@sectionname varchar(30),
@ExpensesName varchar(max),

[code]....

View 3 Replies View Related

How Can Avoid Displaying Data Using A Cursor ??

Oct 16, 1998

I defined a stored procedure with a cursor inside for updating data.
When I call it from an MSAccess client, it fails.
When I execute it directly in a ISQL/w windows, it doesn`t fail but it displays me the data (wich is the reason for failing from MSAccess).
Do somebody know if I could do it without displaying data in the screen ??

View 2 Replies View Related

Massive Data Import, How To Avoid Dublicates?

Dec 4, 2006

Hello,

I am currently working on a project where I have to import a huge amount of data from CSV files into a database.
I don't want to have dublicate keys in my table, but my CSV file contains them. That means the line more at the end of the file contains the mor up to date information that I have to store.

I try to fix this problem since serveral weeks, but my algorithm is very slow and blocks all other processes on the server. At the moment I am copying all records into a temp table that occure more than once in the CSV file. After that I am running through this table line by line and check if the key already exists in the target table and then either make an insert or an update.

Does somebody know a better process?

I hope somebody can help me... :(

View 5 Replies View Related

Avoid Cross Database Views In Data Warehouse

May 4, 2007

We have a relational database (rd) and a data warehouse (dw). This dw has a table (tw) with all key fields (dimension keys) and metric related (measures) fields. This table is populated with monthly data each month. The tw is joined to various look up views present in the dw to obtain name fields from rd. The DBA wants me to remove the look up views. I now have following 2 options that I can think of –

1)Further de-normalize the tw and store the name fields as well. However, there are two issues with this option –

a.The size of tw will grow tremendously.
b.We are storing monthly data and the values in the name fields may change after some time. Then we will have to put in additional views/objects to obtain the latest name.

2)Using ETL, obtain the copy of rd tables overnight in dw. We will then join tw with these tables and there will no longer be cross database joins. However, this will be a burden on maintenance and support.

As of now these are the possible options I can come up with. Which one would you suggest and why? If you have another option, please let me know.

Thank you all in advance,

sajmera

View 1 Replies View Related

How Can We Avoid Somebody To Access The MDF Data By Doing User Instance Connection?

Dec 11, 2006

I created a database that will be distributed to my customers. This database is running on an Instance of SQL Server 2005 Express edition. I removed the admin logins from my SQL Server Instance so in theory, only my application connecting itself using the Sql Server autenthication will be able to be access the data (using "sa" having a password that I set at the installation).

For now, all this is working fine and after some tests, I haven't been able to access the data in any ways except by using the "sa" and the password my app is the only one to know.

But the problem is coming from a security leak when using User Instance. Indeed, I've been able to create a program getting the content from my MDF file. If somebody try to get connected using User Instance on his own SQL Server instance, he will be able to reach the data.

How could I prevent this to happend? Is there a property or something that could be set into the database that would prevent the database (mdf file) to be used with User Instance?

Thanks!

View 5 Replies View Related

DB Engine :: How To Avoid Special Characters While Migrating Data

Jun 23, 2015

I have a source sql 2005 with the database collation SQL_Latin1_General_CP1_CI_AS and destination with sql 2012 with the same collation.

But the SQL server llvel collation is different, sql 2005 uses Latin1_General_CI_AI and sql 2012 uses "SQL_Latin1_General_CP1_CI_AS"

Now when i load the data from 2005  for one table to sql 2012 i could see special characters in one column. And i dont see that in the source database. Is there a way to avoid that or is it something we need to manually fix.

View 7 Replies View Related

Retrieving Data From SQL Server Table To Display On Button On Datagrid Table.

Oct 10, 2007

I have nine type of buttons,
EnrollAmtBTM
PlacAmtBTM and so on, I also have a SQL setver view V_Payment_Amount_List from here i need to display the data on the button
this is the select value to display when i choose the agency list and the amount corresponding to that agency_ID is displayed here the agency_ID is fetched from the SQL CONDITION
 THIS IS WHERE I GET FETCH AGENCY DATA WHEN SELECTED i.e SQL CONDITIONprotected void CollectAgencyInformation()
{
WebLibraryClass ConnectionFinanceDB;ConnectionFinanceDB = new WebLibraryClass();
string SQLCONDITION = "";string RUN_SQLCONDITION = "";
SessionValues ValueSelected = null;int CollectionCount = 0;if (Session[Session_UserSPersonalData] == null)
{ValueSelected = new SessionValues();
Session.Add(Session_UserSPersonalData, ValueSelected);
}
else
{
ValueSelected = (SessionValues)(Session[Session_UserSPersonalData]);
}ProcPaymBTM.Visible = false;PaymenLstBTN.Visible = false;
Dataviewlisting.ActiveViewIndex = 0;TreeNode SelectedNode = new TreeNode();
SelectedNode = AgencyTree.SelectedNode;
SelectedAgency = SelectedNode.Value.ToString();
Agencytxt.Text = SelectedAgency;
Agencytxt2.Text = SelectedAgency;
Agencytxt3.Text = SelectedAgency;DbDataReader CollectingDataSelected = null;
try
{CollectingDataSelected = ConnectionFinanceDB.CollectedFinaceData("SELECT DISTINCT AGENCY_ID FROM dbo.AIMS_AGENCY where Program = '" + SelectedAgency + "'");
}
catch
{
}DataTable TableSet = new DataTable();
TableSet.Load(CollectingDataSelected, LoadOption.OverwriteChanges);int IndexingValues = 0;foreach (DataRow DataCollectedRow in TableSet.Rows)
{if (IndexingValues == 0)
{SQLCONDITION = "where (Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
else
{SQLCONDITION = SQLCONDITION + " OR Project_ID = '" + DataCollectedRow["AGENCY_ID"].ToString().Trim() + "'";
}
IndexingValues += 1;
}SQLCONDITION = SQLCONDITION + ")";
ConnectionFinanceDB.DisconnectToDatabase();if (Dataviewlisting.ActiveViewIndex == 0)
{
Dataviewlisting.ActiveViewIndex += 1;
}
else
{
Dataviewlisting.ActiveViewIndex = 0;
}
SelectedAgency = SQLCONDITION;
ValueSelected.CONDITION = SelectedAgency;
 
 
???? this is where i use to get count where in other buttons and are displayed.... but i changed the query to display only the Payment_Amount_Budgeted respective to the agency selected. from the viewRUN_SQLCONDITION = "SELECT Payment_Amount_Budgeted FROM dbo.V_Payment_Amount_List " + SQLCONDITION;
try
{
CollectionCount = ConnectionFinanceDB.CollectedFinaceDataCount(RUN_SQLCONDITION);
EnrollAmtBTM.Text = CollectionCount.ToString();
}
catch
{
}////this is my CollectedFinaceDataCount-- where fuction counts the records in the above select statement if i use for eg.
"SELECT Count(Placement_Retention_ID) FROM dbo.V_Retention_6_Month_Finance_Payment_List"
here is the functionpublic int CollectedFinaceDataCount(String SQLStatement)
{int DataCollection;
DataCollection = 0;
try
{
SQLCommandExe = FinanceConnection.CreateCommand();
SQLCommandExe.CommandType = CommandType.Text;
SQLCommandExe.CommandText = SQLStatement;
ConnectToDatabase();DataCollection = (int) SQLCommandExe.ExecuteScalar();
DisconnectToDatabase();
}catch (Exception ex)
{Console.WriteLine("Exception Occurred :{0},{1}",
ex.Message, ex.StackTrace.ToString());
}
 return DataCollection;
}
 
 
So here mu requirement request is to display only the value fronm the view i have against the agency selected
Please help ASAP
Thanks
Santosh

View 8 Replies View Related

Howto Get Avoid Bulk Insert Data Conversion Error?

Aug 7, 2006

hi, i having a problem in bulk insert , which is regard the text file that
to insert into database, when insertion processing,

if my textfile have NULL value, it give me Bulk insert data conversion error

for example in my text file c:mytest.txt , it contains data NULL

123 studentname NULL



can we let bulk insert detect NULL value ?

i have try on putting "KEEPNULLS" , but it doesn't help , caused some fields in table may in datetime type

BULK INSERT [mytable] FROM c:mytest.txt WITH (FIELDTERMINATOR = '' '', ROWTERMINATOR = '''', KEEPNULLS )'


thank you

View 4 Replies View Related

REPEATED RECORDS

Feb 21, 2007

Why this SQL procedure gives contiguous repeated records ( 3 or 4 times ) ?
 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ALTER PROCEDURE GetProductsOnPromotInDep
(@DepartmentID INT)
AS
SELECT   Product.ProductID, Title
FROM Product INNER JOIN  
(ProductCategory INNER JOIN
(Category INNER JOIN Department    ON Department.DepartmentID = Category.DepartmentID)
  ON ProductCategory.CategoryID = Category.CategoryID)
  ON Product.ProductID = ProductCategory.ProductID
WHERE Category.DepartmentID = @DepartmentID
AND ProductCategory.CategoryID = Category.CategoryID
AND Product.ProductID = ProductCategory.ProductID
AND Product.OnPromotion = 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View 2 Replies View Related

Repeated Character In String

Jun 19, 2006

How can find out the repeated character in each row value of spacific column

View 1 Replies View Related

Display Repeated Records

Mar 5, 2014

finding the solution for the below query?It displays repeated records.

select distinct ku.username,rro.role_name,rp.resource_type_code,kr.region_name,kc.currency_name,
fcr.cost_rule_id RULE,fcr.rate current_rate,pp.project_name,kou.org_unit_name ORG_UNIT
from

[code]....

View 2 Replies View Related

SELECT The Repeated-same Rows

Feb 5, 2008

Hi!

I am beginner on using SQL.
How can I select the repeated rows (five or more times) on a table which have the same ID's but different updated date. I do not need to group all the rows with the same ID,s but rows which are repeated many times according to the required reports needed.

Below are some information regarding tables and views:

VIEW name= dbo.tblCCInvoicesH
COLUMN ID= ConsumerID
COLUMN DATE= ReadingDate

Thank you in advance...

meti

View 1 Replies View Related

Repeated Alert E-mails

Mar 10, 2008

Hi
I have created a Percent Log Used Alert with a threshold of 85% and am getting e-mailed with Database Mail, the problem is that I continue to get e-mailed repeatedly with the same e-mail until I disable the Alert. Is there any way to have it just e-mail it once?

Thanks
Pam

View 3 Replies View Related

SQL Way To Suppress Repeated Values

Feb 26, 2007

This is a problem I usually solve with procedural code, but I am wondering how/if it could be done with SQL queries.

A simple one to many query like:

Select inv.invnbr, inv.freight, invline.quantity, invline.partnbr, invline.cost from inv inner join invline on inv.id = invline.InvID

Returns something like:

invnbr freight quantity partnbr cost

100 50 3 abc 50
100 50 6 def 65
100 50 10 ghi 70

Is there way I can rewrite the query, or add a subquery such that the result set would be:

invnbr freight quantity partnbr cost



100 50 3 abc 50

100 0 6 def 65

100 0 10 ghi 70

Eg, the freight value, which comes from the one/header table, would show up in only one of the lines for invnbr 100?

Many thanks
Mike Thomas

View 9 Replies View Related

Excluding Repeated Values In A Sum

May 21, 2007

The scenario is as follows:

I have rows coming from the db including:
Contract Number, Contract Name, owner and Actions associated with each contract.

SQL statement brings back:
Contract Number Contract Name Sales Owner Action
1234 123453 $50 Neil x
1234 123453 $50 Bob y
534232 5464634211 $30 Harry z

The problem is that each contract can have multiple actions associated with it...
There ideal output would be:

Contract Number Contract Name Sales Owner Action
1234 123453 $50 Neil x
Bob y
534232 5464634211 $30 Harry z

Total: $80

Basically I need to hide and not include repeated items based on a contract number... one idea I had was creating a group based on contract number and then display info in the header and then only owner and actions in the detail section.. The problem is Totals... how can I can it to avoid count the duplicated values..

Any help would be greatly appreciated.

Thanks,
Neil

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved