How To Read Filename
Mar 28, 2008HI,
I am writing data from a file in to a table and i have a field in that table for filename. How to read the file name to write in that table.
Thanks in advance.
HI,
I am writing data from a file in to a table and i have a field in that table for filename. How to read the file name to write in that table.
Thanks in advance.
I'm trying to read the filename from a file that I'm downloading by FTP (FTP Component) into a string variable so I can later use it for another part of the process, how can I do this?
View 2 Replies View RelatedHello
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
Doesn't appear you can do this.
Am I wrong?
Please tell me I am.
Hi Champs,
Scenario Configuration : VB.net 2005 Code, WebService for Executing SSIS on Server, SSIS deployed on the Database Server
Problem Description : We are developing windows applicaiton in which we call webservice which was deployed on the same server where SSIS packages are deployed.
Now from Code we are passing FilePath name in variable and execute the Package. But the SSis result says that
The file name "\computernamefol1fol2fol3fol4abc.txt" specified in the connection was not valid.
More Information:
1. Full Permission are given on this network folder.
2. Package executes successfully from SSIS development solution (BIS solution)
3. Deployed packed executes successfully from the Database Server.
4. From Development pc packege executes successfully.
5. Other packages deployed on the same server executed suucessfully with same configuration and scenario.
Only this package is not executing.
-- the only differece with this package with other is -
using ".txt" extension in Flat file connection and using VB Script task
Can any one suggest the appropirate solution for this problem...
Thanks
Tarang Pandya
i attached adventure works in sql server 2008 and it showing as read only ,make it read write or remove read only tag from database.
View 11 Replies View RelatedHow to identify whether the files are in read write or read only?
View 1 Replies View RelatedI'm trying to do Sharepoint DR with Log Shipping and every thing configured except one thing which is switch the WSS_Content (Standby /Read-Only) DB to be ready and Write.Â
I tried from
GUI or ALTER DATABASEÂ [WSS_Content]Â SET
READ_WRITEÂ WITHÂ NO_WAIT
but I received the below error:Â
Database WSS_Content is in Warm StandbyÂ
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
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.
i have a database which get refreshed every day from client's data . and we need to pull heavy data from them every day as reports . so only selects happens on that database.
we do daily population of some table in some other databases from this daily refreshed DB.
will read uncommitted or NOLOCK with select queries to retrieve data faster.
there will be no dirty read as there are NO DML operation in that database so for SELECT which happens concurrently on these tables , will NOLOCK work?
Can a user of db owner role of a database change the databse option to read only and read-write?If not what permission I need to grant to the user?
View 1 Replies View RelatedIs 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 1 Replies View RelatedOK, I'm using VS2003 and I'm having trouble. The page works perfectly when I created it with WebMatrix but I want to learn more about creating code behind pages and this page doesn't work. I think it has some things to do with Query builder but I can't seem to get change outside "please register". I have the table populated and it is not coming back with "login successful" or "password wrong" when I've entered correct information. Enclosed is what I've done in VS2003. Can you see where my error is? Any help would be greatly appreciated.
Thanks again.
Imports System.data.sqlclient
Imports System.Data
Public Class login2
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection
Me.SqlCommand1 = New System.Data.SqlClient.SqlCommand
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "server=LAWORKSTATION;user id=sa;database=test;password=t3st"
'
'SqlCommand1
'
Me.SqlCommand1.CommandText = "SELECT pass FROM Customer WHERE (email = 'txtusername.text')"
Me.SqlCommand1.Connection = Me.SqlConnection1
End Sub
Protected WithEvents lblUsername As System.Web.UI.WebControls.Label
Protected WithEvents lblPassword As System.Web.UI.WebControls.Label
Protected WithEvents txtUsername As System.Web.UI.WebControls.TextBox
Protected WithEvents txtPassword As System.Web.UI.WebControls.TextBox
Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
Protected WithEvents lblMessage As System.Web.UI.WebControls.Label
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents SqlCommand1 As System.Data.SqlClient.SqlCommand
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Private Sub btnSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
SqlConnection1.Open()
Dim dr As SqlDataReader = SqlCommand1.ExecuteReader
If dr.Read() Then
If dr("password").ToString = txtPassword.Text Then
lblMessage.Text = "login successful"
Else
lblMessage.Text = "Wrong password"
End If
Else
lblMessage.Text = "Please register"
End If
dr.Close()
SqlConnection1.Close()
End Sub
End Class
If you use "SELECT filename FROM sys.sysdatabases" this will return
the full path , such as "E:MSSQLdatamyData.MDF" ,
is it possible to return just the "myData.MDF" part of it?
I know that you can parse the string , but is it stored somewhere else , or is there a command that will return just the physical file name ?
Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Hi Guys, got a question that I'm not sure there is an answer to other than 'No Way'.
I have to export a file whose filename must include a sequence number. I have created the table to hold the seq# and the code to increment it. My problem is how do I include the seq# in the output filename. I am using the Flat File Destination tool for exporting. should I be using another tool?
Any suggestions?
Thanx,
Trudye
Hello,
Is there any way to change the logical filename of exsiting database
Thanks
Lara
Does anyone know how to execute a directory listing of a file and return the file name to a variable in SQL? For instance, there's a file called c:datach20011010.txt and i execute the following:
xp_cmdshell 'dir c:datach*.txt'
or any other transact sql or procedure, how can i get the filename into a variable...all in sql?
FYI - I need to pass a filename to a process so that it can bcp the data into a temp table. But I don't know the filename at the time the process is setup/scheduled.
TIA,
Mike Nolen
Hi,
I am using a foreach loop to go through the .txt files inside a folder.
Using a variable I can pickup the filenames the loop is going through.
At present there is a sql task inside the foreach loop which takes the filename as a parameter and passes this filename to a stored procedure.
Now I would like to add one extra step before this sql task. Would like to have a dataflow with flatfile source which connects to oledb destination.
The question is:
While in the loop, how is it possible to pass the filename to the flatfile source using the FileName variable which I have created?
Please note, this is a different question to my other post.
Many Thanks
Hi,
I think I may have mis-guided some of you in my previous post.
So I thought I explain it properly this time in a new post...
Here is the description of the ssis package:
Inside the connection manager there is a connection to the sql server database and a flat file connection.
The flat file connection inside the connection manager has the expression set
i.e. ConnectionString set to @[User::FileName]
And so there is nothing inside the connectionstring property of this flatfile connection.
Inside control flow:
1)
Dataflow which contains a flat file source and an ole db destination
The flatfile source is supposed to pickup the .csv file that gets passed to the ssis package.
Then the ole db destination is where the .csv gets imported into a sql server table.
2)
Back in the control flow, there is a task that calls a stored procedure with the parameter which is set to FileName
The question is:
How does this FileName parameter gets set before it is passed to the stored procedure?
Many thanks
Hi,
Using a ssis package I have several tasks.
A variable is also created called FileName.
There is a flat file connection called InputFileName.
initially when I designed the package, I hardcoded the pass of one of the .csv files into the path of the flatfile connection.
There is a dataflow which has flatfile source and oledb destination. These two basically pickup the file and import into the database using mapping.
So therefore the package works and data gets imported into the database.
Then I used the variable to make the filename dynamic. So I removed the hardcoded connectionstring in the InputFileName.
Is this the right thing to do to make the package dynamic? I would like to pass in any .csv filename and so the package runs.
My question is now that the connectionstring is deleted but instead placed an expression for the filename, then how does the system know which file to use?
Thanks
Using SSIS foreach loop I get the files names inside a folder on the network.
How do I pass this variable i.e. file name to a stored procedure?
Thanks
Hi, I want to get my SSIS package to look for a file in a named directory that has a ceratin string in the filename.
example - My file is in a folder called data and the filename is 'System_UT_INCR_BOOKINGHEADER_20080214000000.TXT' Every day the fiel name changes to reflect the current date. I need my package to search for the String "BOOKINGHEADER". I know I need to create a variable with that value but I am not sure (using the example below) how to write the code to do this.
Imports System.IO
Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Runtime
Public Class ScriptMain
Public Sub Main()
Try
File.Move(Dts.Variables("Source").Value.ToString, Dts.Variables("Destination").Value.ToString)
Dts.Events.FireInformation(0, "", "File Moved Succesfully", "", 0, True)
Catch ex As Exception
Dts.Events.FireError(1, "", "Source file or destinations does not exist", "", 0)
End Try
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
I take a backupfile every night and its named like 20070911_xvall.bak.
Now I need a procedure for an automatic restore in another sql server but I have to do a check to se that the date of the backupfile is the same as actual date so it can¨t happened that an older backupfile being restored.
Is it a good way to take actual date och build up the wanted filename and how can I then check if the file exist, its stored on another computer?
Anyone who has some sample I can start with?
Thanks
Hello,
I have a question regarding the report file which is included in an email, when a subscription is created:
Is it possible to programmatically add something to the name of the created file of the subscription? I want to have one parameter of the report, which is a date, added at the end of the filename to let the clients distinguish between different report files.
Thank you in advance.
Sandra Geisler
i have four text file which comes in different format , one of the fields i need to generate is the source Filename without extension as one of the coloums in the target tables.
The name of the file is requirment in the destination, how could i read the file name of the text file source and make it a coloumn and insert it into target.
Please advise
How do I correct this error:
"The database filename can not contain the following 3 characters: [ (open square brace), ] (close square brace) and ' (single quote)" ?
Where is the database stored and/or how can I change the relevant settings?
I have Both Visual Web Developer Express and SQL server express.
Exception detail:
System.Web.HttpException was unhandled by user code Message="The database filename can not contain the following 3 characters: [ (open square brace), ] (close square brace) and ' (single quote)" Source="System.Web" ErrorCode=-2147467259 StackTrace: at System.Web.DataAccess.SqlConnectionHelper.CreateMdfFile(String fullFileName, String dataDir, String connectionString) at System.Web.DataAccess.SqlConnectionHelper.EnsureSqlExpressDBFile(String connectionString) at System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) at System.Web.Profile.SqlProfileProvider.GetPropertyValuesFromDatabase(String userName, SettingsPropertyValueCollection svc) at System.Web.Profile.SqlProfileProvider.GetPropertyValues(SettingsContext sc, SettingsPropertyCollection properties) at System.Configuration.SettingsBase.GetPropertiesFromProvider(SettingsProvider provider) at System.Configuration.SettingsBase.SetPropertyValueByName(String propertyName, Object propertyValue) at System.Configuration.SettingsBase.set_Item(String propertyName, Object value) at System.Web.Profile.ProfileBase.SetInternal(String propertyName, Object value) at System.Web.Profile.ProfileBase.set_Item(String propertyName, Object value) at System.Web.Profile.ProfileBase.SetPropertyValue(String propertyName, Object propertyValue) at ProfileCommon.set_MyNewProperty(String value) in c:WINDOWSMicrosoft.NETFrameworkv2.0.50727Temporary ASP.NET Fileslesson04385e3cebf08b8b90App_Code.jqcpv0qn.0.cs:line 24 at _Default.Page_Load(Object sender, EventArgs e) in D:Daniel's DocumentsVisual Studio 2005WebSitesLesson04Default.aspx.vb:line 15 at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Thanks in advance
how can I store a filename in the database, i have some GIF files which i want to show up on report, how can i specify those filename with a path in the database.
i tried manually entering the path c:Dataimages.gif but it didnt work. Can someone pls tell me how to do it.
Regards,
Karen
I have a page called 'upload.vb', which is the code for a file upload project I am working on. I am trying to write the filenames to an SQL database that I have built, but I keep getting this error: Compiler Error Message: BC30201: Expression expected. It doesn't seem to like the @ on line 46 in the VALUES part of my INSERT statement. Can anybody shed any light on this. Thanks. 1 Imports System
2 Imports System.Data
3 Imports System.Configuration
4 Imports System.Web
5 Imports System.Web.Security
6 Imports System.Web.UI
7 Imports System.Web.UI.WebControls
8 Imports System.Web.UI.WebControls.WebParts
9 Imports System.Web.UI.HtmlControls
10 Imports System.IO
11 Imports System.Data.SqlClient
12
13 ''' <summary>
14 ''' Upload handler for uploading files.
15 ''' </summary>
16 Public Class Upload
17 Implements IHttpHandler, IReadOnlySessionState
18
19 Public Sub New()
20 End Sub
21
22 #Region "IHttpHandler Members"
23
24 Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
25 Get
26 Return True
27 End Get
28 End Property
29
30
31
32 Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
33
34 If context.Request.Files.Count > 0 Then
35 ' get the applications path
36 Dim tempFile As String = context.Request.PhysicalApplicationPath
37 ' loop through all the uploaded files
38 Dim j As Integer = 0
39 While j < context.Request.Files.Count
40 ' get the current file
41 Dim uploadFile As HttpPostedFile = context.Request.Files(j)
42 ' if there was a file uploded
43 If uploadFile.ContentLength > 0 Then
44
45 uploadFile.SaveAs(String.Format("{0}{1}{2}", tempFile, "Uploads", uploadFile.FileName))
46 SqlDataSource.InsertCommand = "INSERT INTO tblDocuments(TheFileName) VALUES ('" & @TheFileName & "')"
47
48 End If
49 System.Math.Max(System.Threading.Interlocked.Increment(j), j - 1)
50 End While
51 End If
52 ' Used as a fix for a bug in mac flash player that makes the
53 ' onComplete event not fire
54 HttpContext.Current.Response.Write(" ")
55 End Sub
56 #End Region
57
58 End Class
Hi,
I have inherited a database that has a table called "Resources" that contains a field called "FilePath". FilePath is a VarChar(100) and contains the server path and filename of an XML file on the server hard disk.
I need to join the data in the XML with rows in the "Resources" table (and other tables).
Is it possible to get a Stored Procedure to load the XML file into a temporary table?
Is loading it into a table the best way to do it - or can I join directly to the XML file somehow?
What is the best approach? (I know nothing about XML in SQL Server yet)
Thanks in advance,
Chiz.
Basically like the topic says, I need to populate a filename with data from other columns and im having a tough time doing it.
Code:
UPDATE nice_cls_calls_0027
SET vcarchivepath = 'G:Nice Storageicestorage.safeautonet.netSafe Auto Task - Logger (807101)2006_feb_1SC_807101_'start_time'_'=stop_time'_'=channel'_'=cls_call_id'.aud'
I need start_time, stop_time, channel, and cls_call_id to populate the filename. The first 2 are datetime fields in the db and no conversion is needed for them, just raw data. The remaining two are smallint and raw data is needed there also. Any help would be greatly appreciated. TY
Hi!
Is there a way I can make the source file in my DTS dynamic so that every time I run it using ASP I can tell it which file to use?
I need to use DTS to create a dynamic destination filename based on the value of a field. I tried creating a DTS package using the wizard. It works fine if I wanted a static filename for the destination filename. I tried creating a Dynamic Properties Task by selecting Connection2/OLEDB Properties/Data Source and then using a SQL Statement to return a value for the name of the file. It doesn't seem to run the query everytime the DTS is ran. The first time I run it it names the file correctly but after that it keeps naming the file the old value from the SQL statement. Any idea what I need to do to fix this?
View 5 Replies View Related