Open / Read / Split / Insert / Repeat
Right now I have a web page that when you click on the only button on the page it opens a text file, reads a line from the text file, splits the comma separated line and stores it in to an array 'strData' and then moves on to the next line and repeats this process.
What I want to do before it goes to the next line is insert that strData in to a SQL DB.
This is my InsertCommand for my SqlDataSource1:
InsertCommand="INSERT INTO [Numbers] ([WTN], [DSL_Qualified], [DSL_Qualified_Date], [Equip_1MM], [Line_Trouble], [Sync_Rate], [Res_Bus], [Host_Remote]) VALUES (@WTN, @DSL_Qualified, @DSL_Qualified_Date, @Equip_1MM, @Line_Trouble, @Sync_Rate, @Res_Bus, @Host_Remote)"
Plus the <InsertParameters>:
<InsertParameters>
<asp:Parameter Name="WTN" Type="Int32" />
<asp:Parameter Name="DSL_Qualified" Type="String" />
<asp:Parameter Name="DSL_Qualified_Date" Type="DateTime" />
<asp:Parameter Name="Equip_1MM" Type="String" />
<asp:Parameter Name="Line_Trouble" Type="String" />
<asp:Parameter Name="Sync_Rate" Type="String" />
<asp:Parameter Name="Res_Bus" Type="String" />
<asp:Parameter Name="Host_Remote" Type="String" />
</InsertParameters>
So I'm not sure exactly what to do after this:
while (file.Peek() > -1)
{
string strCSVData = file.ReadLine();
string [] strData = strCSVData.Split(',');
// somehow get strData in to the SqlDataSource1.Insert method??
}
Any help would be appreciated.
Thanks.
View Complete Forum Thread with Replies
Related Forum Messages:
Read The Filename, Split It And Put It In A Table
Hello I'm working on a package which loops through each xml file in a folder. The name of each xml file is put in variable. The format of the filename is something like "part1_part2_part3.xml" I need to store the 3 parts in three different columns of table A The content of the xml file needs to be manipulated ("." needs to be replaced with ",", ....)and put in serveral columns in tableB It's not clear to me yet how to start this but my main concern is read the three parts of the filename. I don't find any task in SSIS which could help me with that. Could someone give me some pointers? Many thanks! Worf
View Replies !
OPEN & READ A FILE WITH EXTENSION Dat
I need to read a binary file with extention *.dat like this: tat.dat and import it in ms sql server 7.0. I can not load the file in Access and Excel. Either Access or excel recognize the binary format. I want to convert it in asccii text-file (*.txt) or *.csv and import it into sql server 6.5/7.0. Thanks for any help Dr Bangaly Diané
View Replies !
Which Is The Best Way To Read From A Txt File And Insert Data Into Sql Server?
Hi, I was wondering which is the best way to read data from a txt file and insert each row into sql. OLE DB Command could be? It will be necesary to work with variables? My txt file will have a defined width (if it is necessary to know). I will have many rows with many columns. I have to map eah column from the txt file to it's corresponding column in sql server and insert data into it for each row. Thanks for your help!
View Replies !
Can Sql Server Read An Outside File And Insert The Contents Into The Database?
hello! i'm an sql server beginer. i was wondering if some of you guys can help me out. i need for the sql server to be able to read an outside file (just text) and be able to run a script that will insert it in the database. it's a dcc output file. we've tried running this script: DROP TABLE tests go DECLARE @SQLSTR varchar(255) SELECT @SQLSTR = 'ISQL -E -Q"dbcc checkdb(master)"' CREATE TABLE tests (Results varchar(255) NOT NULL) INSERT INTO tests EXEC('master..xp_cmdshell ''ISQL -E -Q"dbcc checkdb(master)"''') and it's running good but the problem is the results of the dbcc here did not come from a file but directly after executing the dcc command. is there a way to do it? thank's for the help!
View Replies !
Read Data From A Csv File And Insert It In A Sql Server Databse Table
Hai Everbody, for me in my project i want to read data from a csv file and insert it in a sql server databse table.The csv file may contain n number of columns,but i want only certain columns from that, and insert it in the database table.How to achieve this. Plz help me it is urgent. Thanks in advance. Thanks and regards Biju.S.G
View Replies !
Read A File Name From Network Folder Automatically For A BULK INSERT
Hi again all, Is there a way to read a file name automatically from a network folder? I can successfully bulk insert from this particular folder. The next step is as I add files, I wish to bulk insert the latest file added so the program must make that determination and import that specific file. I can delete the older files if necessary and save them elsewhere but it would still be nice to be able to read the file name. I then wish to store the name of this file, whatever it is, into a field called "SourceFileName" in my table that I am bulk inserting into. Does anyone have an example in dynamic SQL? Thanks. ddave
View Replies !
BULK INSERT From A Text (.csv) File - Read Only Specific Columns.
I am using Microsoft SQL 2005, I need to do a BULK INSERT from a .csv I just downloaded from paypal. I can't edit some of the columns that are given in the report. I am trying to load specific columns from the file. bulk insert Orders FROM 'C:Users*******DesktopDownloadURL123.csv' WITH ( FIELDTERMINATOR = ',', FIRSTROW = 2, ROWTERMINATOR = '' ) So where would I state what column names (from row #1 on the .csv file) would be used into what specific column in the table. I saw this on one of the sites which seemed to guide me towards the answer, but I failed.. here you go, it might help you: FORMATFILE [ = 'format_file_path' ] Specifies the full path of a format file. A format file describes the data file that contains stored responses created using the bcp utility on the same table or view. The format file should be used in cases in which: The data file contains greater or fewer columns than the table or view. The columns are in a different order. The column delimiters vary. There are other changes in the data format. Format files are usually created by using the bcp utility and modified with a text editor as needed. For more information, see bcp Utility.
View Replies !
Repeat Data In My
Hi all, I'm new to SQL Server 2000. There are certain record that always return a repeated data in a colomn. I'm using a very simple sql command. Just select. In quetry analyser it always return a repeated data. Thanks for help
View Replies !
Repeat Line
Hi all I am new in the forum and in SQL I have this code Code: SELECT PersPlac.Name, Zoom1.Descr, Client.PersonID, Client.Name AS CLIENT_NAME,ClientCu.Period,ClientCu.YearID,IVPeriod.PrdDescr,(ClientCu.DebitP/((InvVAT.VATVal+100)/100)),InvVAT.VATVal FROM Client RIGHT JOIN Salesman WITH (READUNCOMMITTED) ON (Client.SalesmanAA = Salesman.AA) LEFT JOIN PersPlac WITH (READUNCOMMITTED) ON (Client.Place = PersPlac.Code) LEFT JOIN Zoom1 WITH (READUNCOMMITTED) ON (Client.Zoom1 = Zoom1.ID) LEFT JOIN CLIENTCU WITH (READUNCOMMITTED) ON (CLIENT.PERSONID=CLIENTCU.PERSONID) RIGHT JOIN InvVAT WITH (READUNCOMMITTED) ON (CLIENT.TAXCAT=InvVAT.TAXCAT) RIGHT JOIN IVPeriod WITH (READUNCOMMITTED) ON (ClientCu.Period = IVPeriod.PeriodID) WHERE Salesman.Name='ΚΟΡΜΠΟΣ ΦΩΤΙΟΣ' AND ClientCu.Period<>0 AND PersPlac.Name<>'Εικονική Γεωγρ. Περιοχή' AND Client.Name='ΦΩΤΕΙΝΙΑ ΑΝΝΑ' and InvVAT.VATVal in (13,19) the code run fine but every line is turn back 4 times. Why? Thanks for the help
View Replies !
Repeat Subreport
Hi all, I am designing a mailing label report. I put the client info. on a sub-report. I want to use a parameter to input the label amount and sub-report will be repeated by that amount. How can I implement this? TIA Micror
View Replies !
Don't Repeat The Same Fruilt A User Ate...
This may get brought up again and again, but I don't know how to deal with it by heart yet... in fact I mean to say, I don't know how to deal with it. With the given data set how do you only return one of the 2 rows where a given user ate the same fruit? apples gregpeach greglemon gregapples greg peach brucepeach brucelemon bruceapples bruce pear paulpeach paulplumb paulplumb paul apples barbpeach barblemon barbpear barb What T-SQL is needed to produce the following dataset? apples gregpeach greglemon greg peach brucelemon bruceapples bruce pear paulpeach paulplumb paul apples barbpeach barblemon barbpear barb
View Replies !
Repeat Charts In Every Page
hi guys, In reporting services i have a table and below which i have a chart. The table has lot of values so the report spans multiple pages. I have set page breaks such that the table displays only 10 records. After all the values have been displayed in the last page the chart is displayed. I want the chart to display in each and every page of the report. It is the same chart that i want to display. How do i do this? plz can anyone give me ideas. Thanks, Sai Abhiram Bandhakavi
View Replies !
Repeat Subtotal In Matrix
I have a report I'm modifying that has columnar data by period and week. At the bottom I have subtotaled it by YTD. I have page breaks by period. I want to see the subtotal at the end of every page. I know for a table, you can choose, "Repeat on New Page". How do I do this in a matrix?
View Replies !
Rectange Within Subreport Will Not Repeat On Every Page
I am attempting to use a rectangle within a subreport to provide the functionality of a header that will be passed back to the main report. However when I check the 'Repeat report item with data region on every page' box and choose a data region it still does not repeat anywhere? My header does not require dynamic fields so I don't need to deal with the hidden field workaround I don't believe. I am wondering if this is a bug that has a workaround or if I am just going to have to do without a header. I would appreciate any suggestions.
View Replies !
Repeat Header Doesnt Work
hi there, i've made a report containing a subreport. the subreport is in a table. the table headers should repeat. but if the subreport expands more than one site, the table header doesnt repeat. okay. i could place the table header in report header, but in report header i cant use fields from a dateset. thanks for any idea, tobi
View Replies !
Finding Max/Min Value In A Column When Row Data Repeat
I have a table. In that table I have a list by student number that lists the entry dates into a particular grade. When trying to list only the first time entered, there is no unique way to identify one row from another other than the date. Is there a way to use max or min to only pull one date per student number? I have done a series of case when statements and I am able to get it down to 1 to 2 entries per student number, but I need to get it down to only 1 date per student number. Thank you for your help SELECT DISTINCT mx.stu_num, CASE WHEN er.STU_NUM = ep.STU_NUM THEN er.enterdater ELSE CASE WHEN ea.STU_NUM = ep.STU_NUM THEN ea.enterdatea ELSE CASE WHEN eb.STU_NUM = ep.STU_NUM THEN ep.enterdatep ELSE eb.enterdateb END END END AS entrydate FROM dbo.mx AS mx LEFT OUTER JOIN dbo.v_EntryDate9_R AS er ON mx.stu_num = er.stu_num LEFT OUTER JOIN dbo.v_EntryDate9_P AS ep ON mx.stu_num = ep.stu_num LEFT OUTER JOIN dbo.v_EntryDate9_A AS ea ON mx.stu_num = ea.stu_num LEFT OUTER JOIN dbo.v_EntryDate9_B AS eb ON mx.stu_num = eb.stu_num
View Replies !
How To Repeat Header Of The Table For Each Record
Hi, In RS 2005 i am using a table to show the multiple records.Now i want to repeat the header of the table for each record of table but dont know how to do this.the layout should like.. Name Address Mach xyz Name Address Peter abc Also how can i make our report multilingual. Pls suggest me. thanks in advance..
View Replies !
Data Starts To Repeat When I Add A Dimension.
Hello, I€™m creating a cube with Analysis services 2000 and SQLServer 2000 that has the following structure: The fact table has a primary key and some measures: Fact_Table PKFact (the primary key) Measure 1 Measure 2 And I have some dimensions, but I€™ll put here the one of interest, this dimension has a foreign key to the fact_table, this is because it is really a €œdetail€? of the fact table, the interesting thing here is that this dimension not only has a foreign key to the fact_table, but also is a parent-child dimension: Dimension_Table FKFact (the foreign key to the €œPKFact€? field of the fact table) PKId (The id of the field for the parent-child relationship) FKParentId (the foreign key to this same table, this is, the parent of the field) TheLevel (the data€¦) So, if I create the cube without the Dimension_Table (of course, I have more dimensions), the cube shows the data correctly, but when I include this dimension, the data of the fact_table starts to be repeated once for each row in the dimension table (once for each row that has the relation PKFact €“ FKFact of course), Somebody knows how I can avoid this data being repeated? I€™ve tried a lot of things but none works.. Please help!! Thanks in advance. Odin_Dark@yahoo.com.mx
View Replies !
Need An Efficient Way To Repeat The Column Headers Of A Table
There are 2 tables tPeople ID Name 1 Arun 2 B 3 C tAddress PeopleID Address 1 Test Address A 1 Test Address B 1 Test Address C 2 Address A 3 Address1 3 Address2 Expected Result ID Name Address1 Address2 Address3 1 Arun TestAdressA Test Address B Test Address C 2 B Address A 3 C Address1 Address2 Address columns repeated = max(count(Address)) for PeopleID Help me on this! I can do it through dynamic sql using Execute sp_executesql Is there any workaround except this?
View Replies !
Table Set To Repeat Header Rows On Each Page But They Don't
I'm using SQL 2000 Reporting Services and building reports on Visual Studio 2003: The table is set to repeat header rows on each page, also the rows are grouped by the 1st column but, when I preview my report: The initial list is not big enough to page but, When I start expanding the groups, the list is long and it doesn't page. When I deploy my report and then export it to a PDF document, if the details of the expanded group is greater than the page height the page then breaks and the row headers are not shown on the following page. Is there a way to get the row headers to show after the page break?
View Replies !
Repeat Header On Every Page Of Report Containing A Matrix
I have a matrix that spans more than one page (both vertically and horizontally). The data section of the matrix contains a sub-report. I want to be able to be able to repeat my report header (another sub-report) on every page. I can't find a way to achieve this. Could somebody point me in the right direction. Thanks.
View Replies !
Repeat A Table Column On Every New Physical Page
Hello, I wonder how and if this can be achieved: In a tabular report I have one or more columns that need to be repeated on every new physical page when printed. Viewing the report in the ReportViewer control allows such columns to be fixed using the "FixedHeader" switch, allowing the user to conveniently scroll the reports content while always having the fixed columns in sight. This is perfect. However, when switching to the Print Layout view or when printing the report, I would like to have these fixed columns be printed on every new page that is generated at the beginning of the table printed. E.g. I have a report that has a huge number of columns that need to be shown. When printed, the columns need at least 6 pages' width. I would be very convenient if I could repeat e.g. the first column (containing some identificational information) on every of these 6 pages. It wouldn't hurt if e.g. 7 pages would be generated because of the repeated column(s). Any help is appreciated, thanks a lot! Frank
View Replies !
Reset Database Files From Read-only To Read-write
I have two database files, one .mdf and one .ndf. The creator of these files has marked them readonly. I want to "attach" these files to a new database, but cannot do so because they are read-only. I get this message: Server: Msg 3415, Level 16, State 2, Line 1 Database 'TestSprintLD2' is read-only or has read-only files and must be made writable before it can be upgraded. What command(s) are needed to make these files read_write? thanks
View Replies !
DTS-data Driven Task, Repeat N Times If Failed
Hi, I have one data driven task set up in my DTS package. for some reason the connection to data source is not available when my package is scheduled to run,which fails the package. is there a way, I can set the task to try to execute again after a couple of minutes or 5 mins, maybe a predefined number of times before it fails the package? Thanks & Regards Naseem
View Replies !
Table Join Statement Returns Repeat Rows
Hello All. I am struggling with the below join block in my stored procedure. I can't seem to get the duplicate row problem to go away. It seems that SQL is treating each new instance of an email address as reason to create a new row despite the UNIONs. I understand that if I am using UNION, using DISTINCT is redundant and will not solve the duplicate row problem. Primary Keys: none of the email address columns are primary keys. Each table has an incrementing ID column that serves as the primary key. I am guessing I am encountering this problem because of how I have structured my Join statements? Is it possible to offer advice without a deeper understanding of my data model or do you need more information? Thanks for any tips. Code: select emailAddress from Users union select user_name from PersonalPhotos union select email_address from EditProfile union select email_address from SavedSearches union select distinct email_address from UserPrecedence union select email_address from LastLogin) drv Left Join Users tab1 on (drv.emailAddress = tab1.emailAddress) Inner Join UserPrecedence tab5 on tab5.UserID=tab1.UserID Left Join PersonalPhotos tab2 on (drv.emailAddress = tab2.user_name) Left Join LastLogin tab4 on (drv.emailAddress = tab4.email_address) Left Join EditProfile tab3 on (drv.emailAddress = tab3.email_address) Left Join SavedSearches tab6 on (drv.emailAddress = tab6.email_address
View Replies !
Repeat A Textbox For Multiple Physical Pages Of Matrix
Hi All - I have a local SSRS report (rdlc) that is called from a WinForms app. This contains multiple matrices with a single textbox above each for the title. Everything works fine except when exported to pdf/print preview the columns expand horizontally accross multiple pages and the textboxes do not repeat every page with the matrix. Now I've read that the RepeatWith property does not work for this particular example, so I am looking for any workarounds that you all might have came accross. Thanks!!
View Replies !
Read Text File From SQL Server, Read Its Content, And Load It In RichTextBox (Related Component: Context.Response.BinaryWrite(), And StreamReader)
OBJECTIVE: I would like to read a text file from SQL Server 2000, read the text file content, and load its conntents in a RichTextBoxTHINGS I'VE DONE AND HAVE WORKING:1) I've successfully load a text file (ex: textFile.txt) in sql server database table column (with datatype Image) 2) I've also able to load the file using a Handler as below: using System;using System.Web;using System.Data.SqlClient;public class HandlerImage : IHttpHandler {string connectionString;public void ProcessRequest (HttpContext context) {connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["NWS_ScheduleSQL2000"].ConnectionString;int ImageID = Convert.ToInt32(context.Request.QueryString["id"]);SqlConnection myConnection = new SqlConnection(connectionString);string Command = "SELECT [Image], Image_Type FROM Images WHERE Image_Id=@Image_Id";SqlCommand cmd = new SqlCommand(Command, myConnection);cmd.Parameters.Add("@Image_Id", System.Data.SqlDbType.Int).Value = ImageID;SqlDataReader dr;myConnection.Open(); cmd.Prepare(); dr = cmd.ExecuteReader();if (dr.Read()){ //WRITE IMAGE TO THE BROWSERcontext.Response.ContentType = dr["Image_Type"].ToString();context.Response.BinaryWrite((byte[])dr["Image"]);}myConnection.Close();}public bool IsReusable {get {return false;}}}'>'> <a href='<%# "HandlerDocument.ashx?id=" + Eval("Doc_ID") %>'>File </a>- Click on this link, I'll be able to download or view the file WHAT I WANT TO DO, BUT HAVE PROBLEM:- I would like to be able to read CONTENT of this file and load it in a string as belowStreamReader SR = new StreamReader()SR = File.Open("File.txt");String contentText = SR.Readline();txtBox.text = contentText;BUT THIS ONLY WORK FOR files in the server.I would like to be able to read FILE CONTENTS from SQL Server.PLEASE HELP. I really appreciate it.
View Replies !
Cannot Open User Default Database. Login Failed. (only When IDE Is Open)
I get the below error only when my IDE open. It connects well when it is found closed. [SqlException (0x80131904): Cannot open user default database. Login failed.Login failed for user 'JPASPNET'.] I could solve this by giving the logged in windows user to impersonate under IIS window > WEBSITE > ASP.NET tab > EDIT CONFIG > APPLICATION tab But I wish someone could give me the proper solution. I almost tried all from giving ASPNET user as a administrator to configuring the same in Express management tool. Environment: XP pro, VWD and SQL Express
View Replies !
Repeat Report Item With Data Region On Every Page - Not Working
I've never attempted to use the "Repeat Report Item with Data Region on Every Page " feature before. I'm trying to use it on text boxes with the data region being a matrix. I have a report that is two pages, and the text boxes are only appearing on the first page. Also, the matrix is appearing with zero space between it and the header. Any ideas? Lindsay
View Replies !
Leave The Connection Open Or Always Open And Close Immediately?
Hi there, I got an approach like that: 1) Read something from DB - check the value, if true stop if false go on2) Read the second Value (another SQL Statement) - check the value etc. Now I could open the connection at 1) and if I have to go to 2) I leave the connection open and use the same connection at 2). Is it ok to do that? The other scenario would be opening a connection at 1), immediately close it after I read the value and open a new connection at 2). Thanks for the input!
View Replies !
Set READ UNCOMMITTED (dirty Read) At Login.
Is it possible to set READ UNCOMMITTED to a user connecting to an SQL2000 server instance? I understand this can be done via a front endapplication. But what I am looking to do is to assign this to aspecific user when they login to the server via any entry application.Can this be set with a trigger?
View Replies !
Multipage Report Repeat Header Not Showing Data From Page 2 Onwards
I am using reportitem to show the data in the header from a table cell.i see the values just on the first page, from second page onwards reportitems not showing the values at all. I am getting the reportitems values from a tables header cell and also made the tables header cell's property checked repeat header in all pages. Header is appearing but the values in reportitems are not populating from page 2 onwards. i tried / used everything including inserting group header still i don't get it towork. please help.......................
View Replies !
Repeat Instlation Of SQL Server 2005 Express Edition Service Pack 2
Hi there, is there anyone that can help here? I have been installing the service pack 2 for a few weeks now. Everytime I install it and error comes up at the end of the install saying that it wasent installed. I visited the newsgroup and read that I should get rid of ACT7 in my SQL Server Configuration Manager which I have done, now the Service pack installs just fine but two minutes later it wants to install again. Any ideas? mally
View Replies !
REPLACE In Derived Column Transform Causing Repeat Data In Rows That Should Be Blank
W2k3 server, SQL 2005. @@version = Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 1) I have my first SSIS package almost working, but I'm having an odd problem and can't find any information to help resolve it. I'm importing from a flat file (csv) to an existing table (append). I've got a Derived Column transformation in the middle to do some data cleanup. It's all working except for one little problem... One of the transformations is 'REPLACE([Column 3],"^","; ")', output to a new column. (The input file has a field that uses carets as delimiters between an unknown number of items; I'm changing that to semicolons for easier reading.) Not all rows have data in this column, some will have one item, some will have multiple items. The REPLACE works except that it fills in repeated data for all the blank rows. Example: Incoming data is: 1 Smith,Jane^Jones,Jane 2 Brown,John 3 4 Adams,James^Adams,Jim 5 6 White,Debra Data inserted into the table is: 1 Smith,Jane; Jones,Jane 2 Brown,John 3 Brown,John 4 Adams,James; Adams,Jim 5 Adams,James; Adams,Jim 6 White,Debra I've tried to use a Conditional to skip the empty rows, but I can't get that working at all (get syntax errors no matter what I put in). Any suggestions on how to fix this would be most appreciated! Thank you.
View Replies !
|