How Can You Stop And Cycle Through A Column(s) Of Data?
Jun 16, 2007
Ok, at this point I have the reader reading the tables data in a loop while it's not empty. During the gathering of each row of data, I was wondering if it was possible to do a next row once I've reached a certain column. The main users table has just the one user, but it's relationship table has a couple family members. I was hoping someone could show me how to make it so that the one user and all his related family members will print out to a label.
while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();
if (usrNmeLbl.Text == usr)
{
if (psswrdLbl.Text == pss)
{
//read the column from the reader and cast it to String as some may contain null values
usrNmeLbl.Text = reader["FirstName"].ToString() + " ";
psswrdLbl.Text = reader["LastName"].ToString() + "<br />";
psswrdLbl.Text += "Place of Birth: " + reader["BirthPlace"].ToString() + "<br />";
psswrdLbl.Text += "<img src=" + reader["Photo"].ToString() + " />" + "<br />";
Label4.Text = "Your relatives: " + "<br />";
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
}
If I grab the Relation table data again, it's not cycled to the next relative. I was hoping that it would, but it's not. So I'm wondering if there was something that could be added to the second set.
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
Thank you in advance.
View 3 Replies
ADVERTISEMENT
Jun 16, 2007
Ok, at this point I have the reader reading the tables data in a loop while it's not empty. During the gathering of each row of data, I was wondering if it was possible to do a next row once I've reached a certain column. The main users table has just the one user, but it's relationship table has a couple family members. I was hoping someone could show me how to make it so that the one user and all his related family members will print out to a label.
while (reader.Read())
{
string usr = reader["UserName"].ToString();
usr = usr.TrimEnd();
string pss = reader["Password"].ToString();
pss = pss.TrimEnd();
if (usrNmeLbl.Text == usr)
{
if (psswrdLbl.Text == pss)
{
//read the column from the reader and cast it to String as some may contain null values
usrNmeLbl.Text = reader["FirstName"].ToString() + " ";
psswrdLbl.Text = reader["LastName"].ToString() + "<br />";
psswrdLbl.Text += "Place of Birth: " + reader["BirthPlace"].ToString() + "<br />";
psswrdLbl.Text += "<img src=" + reader["Photo"].ToString() + " />" + "<br />";
Label4.Text = "Your relatives: " + "<br />";
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
}
If I grab the Relation table data again, it's not cycled to the next relative. I was hoping that it would, but it's not. So I'm wondering if there was something that could be added to the second set.
Label4.Text += reader["Relation"].ToString() + ": ";
Label4.Text += reader["RelativeFN"].ToString() + reader["RelativeLN"].ToString();
Thank you in advance.
View 2 Replies
View Related
Mar 10, 2005
Quick question (I hope) regarding the cycling of the sql server error logs.
I am looking at implementing a daily / weekly job to run the stored procedure "sp_cycle_errorlog", but was wondering if there was any way of stopping the sql server process cycling the logs automatically when it is started? Therefore the logs will only be cycled when the job runs.
Many thanks.
View 1 Replies
View Related
May 27, 2015
I have a table that contains a list of departments (about 50) and another table that contains helpdesk tickets, each record storing the ID of the department sending the ticket. So I'm trying to count how manay tickets per department, I tought of using a subquery and a WHILE cycle but Its just not happening..I sketch up this query:
Code:
WHILE (SELECT MAX(DepartmentID) AS c FROM dbo.tblDepartment) i < i.c
BEGIN
SELECT COUNT(DepartmentID) AS DepartmentCount
FROM dbo.tblTask
WHERE (DepartmentID = @Variable)
END
how could I build this query or what better way of doing the job there are...
View 1 Replies
View Related
Sep 13, 2007
Hi
uh
im on the blag....
Can someone help me with a script for the following?
7am tuesday, week 1 of the year:
full backup, Trans log backups from between 8am and 10pm and nightly diff @ 10.15pm. both TL backups and Diff backups append to the full file. the next day - weds - exactly the same only without the initialising full backup @ 7am. each day appends to the same weeks backup. this goes all the way through to 10.15pm Monday night which is the last activity on the particular backup file.
7am Tuesday, week 2 of the year:
exactly the same process but writing to a new backup file. backup file is named something useful, like with the date of the Tuesday for example..
ill manually delete things as I need to (once that months data has been written to End-Of-Month tape), but otherwise i'd ideally end up with 52 backup files, each containing a weeks worth of data.
help me obi-wan SQLee. cos I cant bloody do it....
Thanks
Alastair
Methodology
"A computer once beat me at chess - but it was no match for me at kick boxing" - Emo Phillips.
View 6 Replies
View Related
Dec 29, 2005
Hey guys...i've got a problem wif my stored procedures...in which my page keep repeating the same data...so to counter this problem i use SELECT DISTINCT instead of just SELECT..but the problem is when i change SELECT into SELECT DISTINCT...the page will not be display,page error....for your information my stored procures was auto generate from some security sofware...so can guys help me out with my code...
SELECT DISTINCT t.TargetID, 'V' RecordType, t.TargetDNSName [Target DNS Name], t.TargetIPAddress [Target IP], t.TargetIPDisplay [Target IP Display], t.TargetOSName, t.TargetOSRevisionLevel, v.SecChkID, v.Severity, sc.TagName [Tag Name], sc.ChkBriefDesc [Tag Brief Desc], sc.ChkName [Tag Chk Name], CONVERT(NVARCHAR(4000),sc.ChkDetailDesc) [Tag Detail Desc], CONVERT(NVARCHAR(4000),r.RemedyDesc) [Remedy], o.ObjectID, o.ObjectTypeDesc [Object Type Desc], o.ObjectName [Object Name], s.SensorDataID, a.AttributeName, a.AttributeValue, NULL [Port],NULL [Service Name],NULL [Protocol]
FROM #Vulns v INNER JOIN TargetHost t (NOLOCK) ON v.TargetID = t.TargetID INNER JOIN (SecurityChecks sc (NOLOCK) LEFT OUTER JOIN Remedies r (NOLOCK) ON sc.SecChkID = r.SecChkID) ON v.SecChkID = sc.SecChkID INNER JOIN ObjectView o (NOLOCK) ON v.ObjectID = o.ObjectID LEFT OUTER JOIN SensorData1 s WITH (NOLOCK, INDEX(SensorData1_AK3)) ON v.ObservanceID = s.ObservanceID AND s.Cleared = 'n' LEFT OUTER JOIN SensorDataAVP a (NOLOCK) ON s.SensorDataID = a.SensorDataID AND a.AttributeValue IS NOT NULL AND a.AttributeValue != ''UNION ALL
View 16 Replies
View Related
Jan 26, 2007
Scenario: SQL Agent job calls "EXEC msdb.dbo.sp_cycle_agent_errorlog" once a week to cycle the SQL Server Agent log. Job is owned by "sa".
Most servers run this with no problem, but one active node of an active/active SQL Servers cluster fails with the message:
Executed as user: DOMAINSQL_Service. SQLServerAgent Error: The process cannot access the file because it is being used by another process. [SQLSTATE 42000] (Error 22022). The step failed.
The SQLAgent job actually appears to be doing its job... a new SQLAgent.OUT is generated with the event:
(Date/Time)+ [412] Errorlog has been reinitialized. See previous log for older entries.
If I try renaming the file SQLAGENT.OUT, I get the message "It is being used by another person or program," which I expect. If I stop the SQLAgent service, I can rename the file with no problem. Failing over has no effect.
I just don't understand why this job fails for this server. (It should be mentioned the job could be fixed to "Succeed on Failure," but I'd rather not.)
View 14 Replies
View Related
May 29, 2008
need help on logical SELECT cycle
Code Snippet
SELECT empID, unit_date, unit, ISNULL(NULLIF ((unit + DATEDIFF(mm, unit_date, GETDATE())) % 4, 0), 4) AS new_unit
FROM dbo.empList
i have this code
this code change the value field "new_unit" evry month from 1 > 2 > 3 > 4
like this evry 4 month it return to 1 >2..........
------------------------------------------
if i put
unit_date = 01/05/2008
and unit=1
than new_unit=1
IT OK
but
if i put
unit_date = 01/04/2008
and unit=1
than i get new_unit=2
but it should be 3
it dont go backward ok
if i put
unit_date = 01/06/2008
and unit=1
than i get new_unit=4
but it should be 2
it dont go forward ok !
TNX
View 1 Replies
View Related
Jan 2, 2007
I am trying to create a query that will show how much revenue that we have recieved from a customer After the first invoice and I'm having a difficult time creating a query to do it.. I have a customer table and a sales table joined by custno.
SELECT Customer.LastName, Sales.InvDate, Sales.AmtChargeFROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo
The output I'd like is
CustNo, LastName, FirstInvoiceAmount, LifeCycleAmount
Getting the first inv date seems straight forward
SELECT Customer.CustNo, MIN(Sales.InvDate) AS FirstInv FROM Customer INNER JOIN Sales ON Customer.CustNo = Sales.CustNo GROUP BY Customer.CustNo
However getting the amount of that first inv and then getting the sum of all invoices not including the first invoice has me scratching my head.
Can anyone point me in the right direction?
View 2 Replies
View Related
Aug 9, 2015
I have a table with EquipmentNumber, OrderType, BreakdownIndicator and RowID columns and below are the values for one equipmentnumber,
EuipmentNumber OrderType BreakdownIndicator RowId Flag
145812 PM04 1 Yes
145812 PM07 2 Yes
145812 PM07 3 Yes
145812 PM04 4 Yes
145812 PM07 5
145812 PM07 X 6
145812 PM07 7
145812 PM04 8 Yes
145812 PM04 9 Yes
145812 PM04 10 Yes
I need to display the 'Flag' column in the result set as mentioned above to identify the cycle values without breakdown indicator values. Here is the logic for this,
1. Need to set the flag 'Yes' for the cycle values PM04 to PM04 in the OrderType and if there is any breakdownindicator value 'X' then we can not consider that cycle for Flag.
View 12 Replies
View Related
Oct 9, 2015
I have weekly billing cycle. And the billing cycle can start on any day of the week.
Assumption: Start day of week is MONDAY
Hence, the following
DayNumber Day
1 Monday
if start day is 1, then billing cycle is Monday - Sunday
2 Tuesday
if start day is 2, then billing cycle is Tuesday - Monday
3 Wednesday
if start day is 3, then billing cycle is Wednesday - Tuesday
4 Thursday
if start day is 4, then billing cycle is Thursday - Wednesday
5 Friday
if start day is 5, then billing cycle is Friday - Thursday
6 Saturday
if start day is 6, then billing cycle is Saturday - Friday
7 Sunday
if start day is 7, then billing cycle is Sunday - Saturday
For a given date, i need find start date and end date of current billing cycle.
For example, if my billing cycle starts on 3rd day of week (wednesday), then for the input 09-Oct-2015, i need to get two output 07-Oct-2015 and 13-Oct-2015
View 6 Replies
View Related
Aug 17, 2006
How can I get
dbname
ip
domain name
Data path
using TSQL.
how can I stop services using TSQL
Emad
View 8 Replies
View Related
Apr 10, 2008
Hi, this is my first post and I'm relatively new to SSIS so please go easy on me.
Without going into too much detail about it, I've set up a simple SSIS package which does this in a nutshell:
Foreach loop picks up all *.xls files in a given folder
1 - Puts the name of the current spreadsheet into a variable
2 - File System Task copies the current spreadsheet ("abc.xls") to a file called "work.xls"
3 - Data Flow task performs data extraction on "work.xls" and puts it into a SQL server database
4 - File System Task moves "abc.xls" into a "success" folder
Continues with loop - move onto next spreadsheet
This works fine, so long as the spreadsheets all have the same number of columns.
As soon as one of them has a column missing (believe me, this will happen - we're dealing with users here) the package falls over at step 3.
When the package comes across an erroneous spreadsheet, what I'd like to do is move the offending file to a failure folder (making step 4 either a success or failure file move) and carry on with the next one.
I know that you can have an error path (the red line) from any step within the dataflow task, but this doesn't help me because the error lies in the structure of the spreadsheet and not the contents.
I've already come up with a work around whereby each file is moved into the failures folder just after step 2, then moved from the failures folder into the success folder at step 4.
This almost gives me what I want, although of course the package still falls over whenever it encounters a dodgy looking spreadsheet.
Is there any way that I can get the package to do what I'm after?
Many thanks,
Simon
View 1 Replies
View Related
Apr 3, 2012
We are using Office 2010 on Citrix with the RCO Master Data Excel addin. I am getting many calls from users that the Addin has disappeared from the Excel menu. Can re-enable it by going to files->Options->Addins and manage COM addins. Have not been able to work out why it becomes disabled. Any registry setting that I can use to stop it from being disabled?
View 4 Replies
View Related
Aug 20, 2014
I have a table with Million plus records. Due to Running Totals article, I have been able to calculate the Trial_Balance for all months.
Now I am trying to provide a Beginning Balance for all months and the Logic is the Beginning Balance of July would be the Trial_Balance of June. I need to be able to do this for multiple account types. So the two datasets that need to be included in logic is actindx and Calendar_Month.
For actindx of 2 and Calendar_Month of 2014-01-01The Trial_Balance_Debit is 19585.46 This would make the Beginning_Balance of actindx 2 and Calendar_Month of 2014-02-01 19585.46
I am trying to do some type of self join, but not sure how to include each actindx number differently.
Table creation and data insert is below.
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TrialBalance](
[Trial_Balance_ID] [int] IDENTITY(1,1) NOT NULL,
[Code] ....
View 7 Replies
View Related
Apr 22, 2014
We have a large 'History' database that is currently about 4.5TB, with most of that in a datafile that is 4.2TB. We wanted to stop growth on the one large data file and have SQL Server allocate new data to the other data files, but this throws an error when we attempt to change the MAXSIZE settings:
ALTER failed for Database 'History'
MODIFY FILE failed. Specified size is less than or equal to current size.
The SQL Server is saying we can have a max size of 2TB, and anything over that is blocked. Since this is being blocked, the file continues to grow.
Is there any way to cap the growth of the 4.2TB file and not allow any more data to be written to it?
View 1 Replies
View Related
Jul 20, 2005
Hi everyone,I encountered an error "Need to run the object to perform this operationCode execution exception: EXCEPTION_ACCESS_VIOLATION" When I try to import data from Oracle to MS SQL Server with EnterpriseManager (version 8.0) using DTS Import/Export Wizard. There are 508 rowsin Oracle table and I did get first 42 rows imported to SQL Server.Anyone knows what does the above error message mean and what causes therest of the row failed importing?Thanks very much in advance!Rene Z.--Posted via http://dbforums.com
View 1 Replies
View Related
May 12, 2015
Using MDS 2012: I have an entity "XYZ_Entity". In "XYZ_Entity" entity I have 2 domain based Columns "DealerGroup" and "Dealer".
While inserting information into "XYZ_Entity" entity user can select the required dealer group from domain base Dealer Group values. Now for selecting Dealer he wants the dealers to be filter based on selected dealer group and he can select from the filtered list. reason to do that is he don't want to go through thousands of dealers and select an incorrect one.
Is it possible, if yes then how?
View 2 Replies
View Related
Feb 27, 2008
Hi, I was wondering how I can complete a column (which doesnt have an input one) with data.
For example:
I have a sql query which bring data of 3 columns
ID | FISRT NAME | LAST NAME
1 MIKE MORGAN
2 SARA JOHANES
So, I will insert that data in a FLAT FILE CONNECTION MANAGER, which I configured with 3 columns and I did the corresponding mapping in the FLAT FILE DESTINTATION.
Now, If I add one more column in the FLAT FILE CONNECTION MANAGER, I will not have it mapped to a input one, obviously. So, what I need is to add one more column to the flat file destination and complete it with zeros values in it.
Probably I can solve this part by introducing a DERIVED COLUMN and there I can configure the zeros that I want to add to the column. But I'm not sure if I can do that without having a input column.
So, the question will be, how can I add one column to a flat file which doesnt have a input and introduce any value that I want to it?
Hope I was clear
Thanks for your help.
Beli
View 4 Replies
View Related
Jan 9, 2008
I have two tables, one a data table, the other a product table. I want to perform a join on the two tables with values distributed into columns based on the value in the month field.
data_table
product_code month value
350 1 10
350 2 20
350 3 30
product_table
product_code profit_center
350 4520
result_view
product_code profit_center mon1 mon2 mon3
350 4520 10 20 30
My current query gives the following result
result_view
product_code profit_center mon1 mon2 mon3
350 4520 10 0 0
350 4520 0 20 0
350 4520 0 0 30
Any direction toward a solution would be appreciated. Am using SS2005.
View 5 Replies
View Related
Jul 31, 2007
Hi everyone,
I am using SSIS, and I got the folowing error, I am loading several CSV files in a OLE DB, Becasuse the file is finishing and the tak dont realize of the anormal termination, making an overflow.
So basically what i want is to control the anormal ending of the csv file.
please can anyone help me ???
I am getting the following error after replacing the '""' with '|'.
The replacng is done becasue some text sting contains "" wherein the DFT was throwing an error as " The column delimiter could not foun".
[Flat File Source [8885]] Error: The column data for column "CountryId" overflowed the disk I/O buffer.
[Flat File Source [8885]] Error: An error occurred while skipping data rows.
[DTS.Pipeline] Error: The PrimeOutput method on component "Flat File Source" (8885) returned error code 0xC0202091. The component returned a failure code when the pipeline engine called PrimeOutput(). The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.
[DTS.Pipeline] Error: Thread "SourceThread0" has exited with error code 0xC0047038.
[DTS.Pipeline] Error: Thread "WorkThread0" received a shutdown signal and is terminating. The user requested a shutdown, or an error in another thread is causing the pipeline to shutdown.
[DTS.Pipeline] Error: Thread "WorkThread0" has exited with error code 0xC0047039.
[DTS.Pipeline] Information: Post Execute phase is beginning.
apprecite for immediate response.
Thanks in advance,
Anand
View 1 Replies
View Related
Feb 27, 2008
Hi there,
I am a new member of this site and I am not very much aware of T-sql's working.
My question is what if I need to get one column's data to be the heading of another column.
To be very exact I have a school's database. The table I am talking about is of the results of students. The table contains Student ID, Subject ID, Total marks of the subject, Marks obtained in the subject. Now I want to print a report by generating data from this table. Right now the data is something like this
StuID - - - SubID - - - -Tot - - -Obt
1 - - - - - - -1 - - - - - - -50 - - - 38
1 - - - - - - -2 - - - - - - -50 - - - 41
1 - - - - - - -3 - - - - - - -50 - - - 42
1 - - - - - - -4 - - - - - - -50 - - - 40
2 - - - - - - -1 - - - - - - -50 - - - 35
2 - - - - - - -2 - - - - - - -50 - - - 40
2 - - - - - - -3 - - - - - - -50 - - - 42
2 - - - - - - -4 - - - - - - -50 - - - 41
StudentID and SubjectID fields are related to other tables so I can get the names from there but when I need the report I need the data in the form of
StuID - Sub 1 - - - Sub 2 - - - Sub 3 - - - -Sub4
1 - - - - 38 - - - - - - 41 - - - - - - 42 - - - - - - 40
2 - - - - 35 - - - - - - 40 - - - - - - 42 - - - - - - 41
The Subjects can be different for different students so the query should be dynamic instead of hard coding the names of the subjects. I hope I am clear with my question. The subjectIDs or their names will become the headings and they will contain the obtained marks for that subjects in their columns just for the reports. I have also checked the PIVOT function but was not able to do what I wanted.
Thanks.
View 9 Replies
View Related
Dec 2, 2007
in Table A Column is
PriKey No Name
1 1 Apple
2 2 Orange
3 3 Juicy
in Table B column is
Prikey ColumnA Price
1 1 10
2 3 2
3 2 5
TableA.Prikey have Depency with TableB.ColumnA
when I am trying to Delete data from Table A , I got error message becaue the depency
how to delete data when there have depency?
I just know when table have trigger , we can disable trigger before delete Data, and enable trigger when data deleted
does there have a way to disable depency and then enable ?
thank you
View 14 Replies
View Related
Aug 7, 2014
I want to concat data from few column to 2 column.
My database as below:
id name email
1 name1 name1@email.com
1 name2 name2@email.com
2 name21 name21@email.com
2 name22 name22@email.com
Output:
id name email
1 name1,name2 name1@email.com,name2@email.com
2 name21,name22 name21@email.com,name22@email.com
View 1 Replies
View Related
Jul 20, 2005
I have a column of digits I'd like to copy into another column in thesame table. How would I do this?Thanks,Bill
View 1 Replies
View Related
Nov 18, 2015
I have a column with the data as below :-
<Items>
<Item Value="Value1" />
<Item Value="Value2" />
<Items>
How to get this data into seperate columns as
Items
value1
value2
View 2 Replies
View Related
Sep 3, 2007
Hi There
This one has bothered me ever since sql server 2000.
When you do an insert into a table with literally hundreds of char or varchar columns and you get the error that the insert failed due to data loss/truncation on a column.
Is there anyway in 2005 to actually find out what column ? Since there are hundreds is is literally a long process of going though each column 1 by 1 manually.
The database engine surely MUST know what column this occurred on so why can it not tell you which column the truncation occurred on ?
Can this be done in 2005 if not will this information be available in 2008 ?
Thanx
View 7 Replies
View Related
Jun 19, 2008
Hi,
I am having problem in bulk update of a sql server table haning identity column from a datatable( has no identity column) using sqlbulkcopy. I tried several approaches, but it does not show any error nor is the table getting updated. But the identity value seems to getting increased every time.
thanks.
varun
View 6 Replies
View Related
Aug 7, 2006
need some help converting a table which has one row for each year. Displaying the data so the each row will contain all of the information for the title and all of the years displayed in separate columns.
I have a SQL Querry which returns the data looking like this (the querry is grouping by Title and by year, then adding up the quantity of rows):
Basic Information needed for Life Insurance 25 2005
Basic Information needed for Life Insurance 45 2006
Ea Chairmans Conference 10 2005
EA Chairmans Conference Press Release 33 2005
EA Chairmans Conference Press Release 21 2006
EA Chairmans Inner Circle Press Release 16 2005
EA Chairmans Inner Circle Press Release 46 2006
EA Honor Ring Press Release 13 2005
EA Honor Ring Press Release 35 2006
EA National Conference Press Release 6 2005
EA National Conference Press Release 9 2006
I need this data displayed like this:
Title 2005 2006
Basic Information needed for Life Insurance 25 45
Ea Chairmans Conference 10 10
EA Chairmans Conference Press Release 33 21
EA Chairmans Inner Circle Press Release 16 46
EA Honor Ring Press Release 13 35
EA National Conference Press Release 6 9
What I want to do is to basically say:
If Row 1 Title = Row 2 Title and Row 1 Year = Row 2 (Year + 1)) Then
add to grid Row 1 Title, Row 1 Qty, Row 2 Qty
Skip Row 2 and go to Row 3 (repeat this step until end of data)
End
Is there any way in the SQL querry to retrieve this data in this format so that I can display it in a datagrid?
Is there any way to display the data in this pattern.
Below is the code I am using now, but since the moving of the data is done in code it is very slow.
****************** Global Variables
Dim dbName As String = "Region_Web_Page_Hits"
Dim ColumnCount As Integer
Function ReturnColumnHeaderAndHitsDataSet() As System.Data.DataSet
'******** This will bring back the column Headers and Gross Hits per Column
Dim ColumnHeaderAndHitsQueryString As String = "SELECT DISTINCT TOP 100 PERCENT " & _
"YEAR(dat_Date) AS str_Year, COUNT(str_PageName) AS int_YearHits " & _
"FROM dbo.tbl_web_page_hits " & _
"WHERE (str_URL LIKE N'%press_Release%') " & _
"GROUP BY YEAR(dat_Date) " & _
"HAVING (Not (Year(dat_Date) Is NULL)) " & _
"ORDER BY YEAR(dat_Date)"
Dim ColumnHeaderAndHitsDataSet = LoadDataArray(ColumnHeaderAndHitsQueryString, dbName)
Return ColumnHeaderAndHitsDataSet
End Function
Function ReturnTableDataSet() As System.Data.DataSet
'This query string will return the data needed to display the report.
Dim TableQueryString As String = "SELECT TOP 100 PERCENT " & _
"str_PageName, COUNT (str_PageName) AS int_Hits, YEAR(dat_Date) AS str_Year " & _
"FROM dbo.tbl_web_page_hits WHERE str_URL LIKE '%Press_Release%' " & _
"GROUP BY str_PageName, YEAR(dat_Date) ORDER BY str_PageName"
Dim TableDataSet = LoadDataArray(TableQueryString, dbName)
ColumnCount = TableDataSet.Tables(0).Columns.Count
Return TableDataSet
End Function
'******* Function to Load the Data Array
Function LoadDataArray(ByVal queryString, ByVal dbName) As System.Data.DataSet
Dim ConnectionString As String = ConnectionStr(dbName)
Dim sqlConnection As SqlConnection = New SqlConnection(ConnectionString)
Dim sqlCommand As SqlCommand = New SqlCommand(queryString, sqlConnection)
Dim dataAdapter As SqlDataAdapter = New SqlDataAdapter(sqlCommand)
Dim dataSet As DataSet = New DataSet
dataAdapter.Fill(dataSet)
sqlConnection.Close()
Return dataSet
End Function
Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
If Not Page.IsPostBack Then
Dim Sort_Field As String = ""
dg_Data.DataSource = QueryMethod(Sort_Field)
dg_Data.DataBind()
End If
End Sub
Currently I have a bunch of Classic ASP code which puts the data in to an array and then into a table with a series of if statments, but it is really slow.
I want to bind it to a data grid and if possible let the SQL statement format the data for me.
View 1 Replies
View Related
Mar 12, 2007
Hello,
I have a problem i'v been searching all day but i can't find an answer anywhere maybe someone here can help.
What I want to do is give a column in a table the same value as another column from the same table. For example:
Table:Requests
A request has a relatedrequestId wich links another request to it. Now I want the date from the linked request in the date from the master request. Because all the master requests date's are empty and i want them to have the date from the linked request.
View 6 Replies
View Related
Sep 4, 2015
I need to create a function that replaces the data in a column with an 'X' based on the LEN of the data in the column. I created one that does a replacement, but it fills the column based on the max data length, and not the current length of the string or integer. An example of what I'm trying to accomplish.
Original data in a varchar(30) column:
thisisavalue
thisisanothervalue
thisisanothervalueagain
shortval
replaced with
xxxxxxxxxx
xxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
xxxxxxx
My current function is replacing the data like this:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
View 4 Replies
View Related
Aug 28, 2015
I have to value [CreateDate] in the data pump of my Flat File Source into my OLE DB Destination SQL Server Table. With a Variable within the SSIS Package or with a Derived Column task within the Data Flow between the Flat File Source and OLE DB Destination?
View 2 Replies
View Related
Sep 10, 2007
Hi i am trying to do a straight forward load from a Flatfile source , i have defined the columns according to the lenghts defined in the Data Dictionary Provided but when i am trying to run the Task i am encounterring this error
The column data for column "Column 20" overflowed the disk I/O buffer.
I tried to add another column 21 at the end and truncate or leave that column unmapped to destination but the same problem occurs for column 21 what should i do to over come this .
In case of Bad Data how to clean up the source.. Please help me with this
View 5 Replies
View Related