I have a project of ASP.NET which is a Customer satisfaction Survey, i need to to incorporate the option selected by customer with the a client side text file which i located at the client machine, read a text file on client or should i develop the survey application as window application.
How can I read a file from client's pc? I found out that it required to upload the file to server and read it from the server, what if I want to read it directly from client's pc, can I do that
I have an input type, so a text box which has a browse button next to it. When it is clicked, the file that is selected has it's full path placed into the text box.
Where is the event! Now that I have the path to the file in the textbox of the input type, I want to load each line of this file into a textbox that is able to handle multiline text. I don't want the file to be uploaded to the website. I just want to contents of the file read and placed in a textbox all with one click on the browse button.
I have developed an application where I need to create a page to read data from Excel File and then update it to the database. The code that I wrote works only when the application runs from my machine. When I deployed the application to the server it gave an error- 'C:PRFileIimport_File.xls' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. here is mu code -
protected void InsertData(object sender, EventArgs e) { OleDbConnection oConn = new OleDbConnection (@"Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\PuertoRicoFile\Puertorico_Iimport_File.xls ; Extended Properties=Excel 8.0 "); OleDbCommand oCmd = new OleDbCommand("select * from [Puertorico_Data$]", oConn); oConn.Open(); //Here [Puertorico_Data$] is the name of the sheet in the Excel file where the data is present OleDbDataReader oleDbReader = oCmd.ExecuteReader(); string AgentIP = ""; string TagName = ""; string Status = ""; string Severity = ""; int EventCount = 0; string EarliestEvent = ""; string LatestEvent = ""; while (oleDbReader.Read()) { AgentIP = (string)oleDbReader[0]; // valid(oleDbReader, 0);//Here we are calling the valid method TagName = (string)oleDbReader[1]; //valid(oleDbReader, 1); Status = (string)oleDbReader[2]; //valid(oleDbReader, 2); Severity = (string)oleDbReader[3]; //valid(oleDbReader, 3); EventCount = Convert.ToInt32(oleDbReader[4]); //oleDbReader[0]; //valid(oleDbReader, 4); EarliestEvent = (string)oleDbReader[8]; //validate(oleDbReader, 8); EarliestEvent = EarliestEvent.Substring(0, 19); LatestEvent = (string)oleDbReader[9]; //validate(oleDbReader, 9); LatestEvent = EarliestEvent.Substring(0, 19); InsertDataIntoSql(AgentIP, TagName, Status, Severity, EventCount, EarliestEvent, LatestEvent); } SqlConnection mySQLconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["IssNetworkReportingSystemConnString"].ConnectionString); mySQLconnection.Open(); SqlCommand cmdSql = new SqlCommand("AddMonth_Event_TotalInfo_for_Puertorico", mySQLconnection); cmdSql.CommandType = CommandType.StoredProcedure; dbReader = cmdSql.ExecuteReader(); dbReader.Close(); cmdSql = new SqlCommand("AddQtr_Event_TotalInfo_for_Puertorico", mySQLconnection); cmdSql.CommandType = CommandType.StoredProcedure; dbReader = cmdSql.ExecuteReader(); dbReader.Close(); oConn.Close(); lblMsg.Text = "Data Imported Sucessfully"; lblMsg.ForeColor = System.Drawing.Color.Green; } public void InsertDataIntoSql(string agentIP, string tagName, string Stat,string severity,int eventCount, string eEvent, string lEvent) {//inserting data into the Sql Server SqlConnection mySQLconnection = new SqlConnection(ConfigurationManager.ConnectionStrings["IssNetworkReportingSystemConnString"].ConnectionString); mySQLconnection.Open(); SqlCommand sqlSelect = new SqlCommand("SELECT SeverityID from Severity where SeverityDesc=@SeverityDesc",mySQLconnection); sqlSelect.CommandType = CommandType.Text; sqlSelect.Parameters.Add("@SeverityDesc", SqlDbType.NVarChar).Value = severity; dbReader = sqlSelect.ExecuteReader(); int severityId = Convert.ToInt32(dbReader.Read()); dbReader.Close(); SqlCommand sqlInsert = new SqlCommand("Insert into IdsData_Puertorico(AgentIP,TagName,Status,SeverityID,EventCount,EarliestEvent,LatestEvent)" + " values (@AgentIP,@TagName,@Status,@SeverityID,@EventCount,@EarliestEvent,@LatestEvent )" ,mySQLconnection); sqlInsert.CommandTimeout = 0; //timeout unlimited sqlInsert.CommandType = CommandType.Text; sqlInsert.Parameters.Add("@AgentIP", SqlDbType.NVarChar).Value = agentIP; sqlInsert.Parameters.Add("@TagName", SqlDbType.NVarChar).Value = tagName; sqlInsert.Parameters.Add("@Status", SqlDbType.NVarChar).Value = Stat; sqlInsert.Parameters.Add("@SeverityID", SqlDbType.Int).Value = Convert.ToInt32(severityId); sqlInsert.Parameters.Add("@EventCount", SqlDbType.Int).Value = Convert.ToInt32(eventCount); sqlInsert.Parameters.Add("@EarliestEvent", SqlDbType.DateTime).Value = DateTime.Parse(eEvent); sqlInsert.Parameters.Add("@LatestEvent", SqlDbType.DateTime).Value = DateTime.Parse(lEvent); sqlInsert.CommandType = CommandType.Text; sqlInsert.ExecuteNonQuery(); mySQLconnection.Close(); }
I have some code in my default.apsx.cs file that all works except one very small but important piece.. I have the same code in c# consoleapp and it works fine on my local machine.
Here is the code...
[code]...
When i try and run it through visual web developer it seems to feel the file doesnt exits so evaluates the if statement to false and moves. on... I havent specified a path and have the file in the same folder as the default.aspx.cs file.
I have a txt file, in which read only property is true. When I try to write some text in that file through the vb coding, it's through the error. I have shown the code below.
Dim fs As FileStream = File.OpenWrite(HttpContext.Current.Server.MapPath("Include/CacheKeyFile.txt")) Dim sw As New StreamWriter(fs) sw.Write("Menu setup updated by " & value & " on " & DateTime.Now.ToString()) sw.Close() fs.Close()
I found the cause of the error. If we set the Write access property to false, we can open the file and write it without showing the error messages.
I need to remove the Read only property for a file through the vb. Net code. Is it possible? Can we set the read only for txt file before open and write operation?
I want to read a text file and separate the data and write it back to another text file. So the input file content is like 07090000079011110225000 00001000100010118832 032111050111205011110501111022500000FL .... I know that first 3 characters are for CompanyID, next 2 are for Symbol etc. How Can I put it together? I used to write in VB code like this below using a Type and define the width there.(easy to maintain) How can I do that in VB.Net or c#?
[Code]....
So the output will be like CompanyID : 070 Symbol :90 .
How do I read/write a text file on another server from a web page.I get the error "Access to the path '//Server2/mydatafiles/test.txt' is denied". I do not get the error if I am running the browser on the server where the files exist.I think I need to set permissions on the destination server in some way.
I have a text file stored in my sql DB. in that .txt file I have certain numbers like:
99435 87889 33455 33555 34556
How to get the count of these numbers from the txtfile stored in the database? Also to read the file and fetch the number one by one in a string? I am using asp.net (C#)
I need to save a text file on the client side possibly without permission. The case is that I need to save this text file in a shared folder in this or in another machine in the lan. This text file is going to be read automatically by the fiscal printer which will print the fiscal invoice. I have a asp .net web application and the server is not on the same lan with the fiscal printer, so I have to write it on the client-side. how to do this without asking to the user every time for the security issue.
I can accept a solution like, the client is asked only one time a the first printing, but not every time he wants to print a bill. Some kind of asking permission to the client for allowing this website, in order to not repeat the permission asking.
In ASP.Net, I want to give a user an ability to save the text entered in the textbox to the client machine. So that, user can copy paste it for later use.
Is there a way to show, save as dialog so that user can save the text in a text file on client machine? or, if there is any other alternative?
I would like ask you for some ideas how can I write mechanism that will be automatically read files from folder. I don't know how to schedule the write task. I want to check for new file everyday and if the new file is in the folder read it.
Anyone know of a way to read out in a list all of the UpdatePanel Client ID's I have on a page? Basically I need to loop through all controls in the page with a type of UpdatePanel, and display the ClientID for each..
I have four update panels on this page and I am using this
private string LoopUpdatePanel(ControlCollection controlCollection) { StringBuilder sb = new StringBuilder(); foreach (Control control in controlCollection) { if (control is UpdatePanel) { sb.Append(((UpdatePanel)control).ClientID + ", "); } if (control.Controls != null) { LoopUpdatePanel(control.Controls); } } return sb.ToString(); }