Click here to Skip to main content
15,888,337 members
Home / Discussions / C#
   

C#

 
QuestionC# Packet Loss Pin
Member 114965273-Mar-15 18:20
Member 114965273-Mar-15 18:20 
AnswerRe: C# Packet Loss Pin
Gerry Schmitz4-Mar-15 3:49
mveGerry Schmitz4-Mar-15 3:49 
GeneralRe: C# Packet Loss Pin
Member 114965274-Mar-15 4:59
Member 114965274-Mar-15 4:59 
GeneralRe: C# Packet Loss Pin
Gerry Schmitz4-Mar-15 11:57
mveGerry Schmitz4-Mar-15 11:57 
QuestionHow to import excel sheet data into postgresql database table in C# Pin
sandy reddy3-Mar-15 2:29
sandy reddy3-Mar-15 2:29 
AnswerRe: How to import excel sheet data into postgresql database table in C# Pin
manchanx3-Mar-15 2:38
professionalmanchanx3-Mar-15 2:38 
QuestionRe: How to import excel sheet data into postgresql database table in C# Pin
ZurdoDev3-Mar-15 2:46
professionalZurdoDev3-Mar-15 2:46 
AnswerRe: How to import excel sheet data into postgresql database table in C# Pin
V.3-Mar-15 20:19
professionalV.3-Mar-15 20:19 
Please update your question with what you have done so far and where you are stuck.
In case of complex problems, make sure to divide your problem in smaller problems.

1. Read in an excel file. This is your first. You can use the excel binaries and reference them in your C# application. From there you can use several functions to open a document and read it in. If it's a csv file you can just use a StreamReader class as csv is not an excel file, but an ASCII file (that excel just happens to understand, more or less) Google : "C# read excel file" and I'm sure you get sample code thrown at you in the results.

2. When you are able to open and read a file make sure to create objects able to hold the records. This object should also check the input for validity and quality, not allowing to add the record if wrong or at least log it somewhere/somehow

3. Now that you have a list of your objects and a database to hold the data you need to create a postgresql connection and write the data to the database (again samples can be found on google). If it is a lot of data you can generate insert queries in a loop eg. To improve performance concatenate the insert queries and only execute by the 100 eg. (make sure to finish the query with ";") Something like this:

C#
StringBuilder builder = new StringBuilder("");
for(int i = 0; i < myrecordobject.Count; i++){
  builder.append("Insert into ...");  //use myrecordobject[i] properties to finish the sql;
  builder.append(";");
  if(i % 100 == 0){
    //Execute the SQL
    builder = new StringBuilder("");
  }
}
//I made this very, very quickly just to give a sample.


4. make sure when writing to the database you also log errors. It is not that data passed the quality test in the object, it also passes the quality check of the database (assuming there are quality checks)


If you do not need to use a C# application perse, maybe have a look if postgresql doesn't allow import from excel.


hope this sets you more or less on your way.
V.

(MQOTD rules and previous solutions)

QuestionDoes the .Net scheduled Timer has a vb version? Pin
PHdeviloth2-Mar-15 20:55
PHdeviloth2-Mar-15 20:55 
QuestionRe: Does the .Net scheduled Timer has a vb version? Pin
Richard MacCutchan2-Mar-15 21:25
mveRichard MacCutchan2-Mar-15 21:25 
AnswerRe: Does the .Net scheduled Timer has a vb version? Pin
F-ES Sitecore2-Mar-15 22:02
professionalF-ES Sitecore2-Mar-15 22:02 
AnswerRe: Does the .Net scheduled Timer has a vb version? Pin
ZurdoDev3-Mar-15 2:45
professionalZurdoDev3-Mar-15 2:45 
QuestionNeed help on FTPS file transmission using X509 Certificates Pin
Satheesh Kumar Subramanian2-Mar-15 18:03
Satheesh Kumar Subramanian2-Mar-15 18:03 
AnswerRe: Need help on FTPS file transmission using X509 Certificates Pin
Richard MacCutchan2-Mar-15 21:24
mveRichard MacCutchan2-Mar-15 21:24 
QuestionStreamReader in TcpListener Pin
Member 114922552-Mar-15 7:14
Member 114922552-Mar-15 7:14 
AnswerRe: StreamReader in TcpListener Pin
Paulo Zemek2-Mar-15 7:45
mvaPaulo Zemek2-Mar-15 7:45 
GeneralRe: StreamReader in TcpListener Pin
Member 114922552-Mar-15 8:25
Member 114922552-Mar-15 8:25 
QuestionDatagridview row replay Pin
sdfsdfsdfewrew3feff1-Mar-15 5:03
sdfsdfsdfewrew3feff1-Mar-15 5:03 
GeneralRe: Datagridview row replay Pin
Richard MacCutchan1-Mar-15 6:15
mveRichard MacCutchan1-Mar-15 6:15 
GeneralRe: Datagridview row replay Pin
sdfsdfsdfewrew3feff1-Mar-15 8:23
sdfsdfsdfewrew3feff1-Mar-15 8:23 
GeneralRe: Datagridview row replay Pin
Richard MacCutchan1-Mar-15 22:38
mveRichard MacCutchan1-Mar-15 22:38 
GeneralRe: Datagridview row replay Pin
Eddy Vluggen2-Mar-15 8:02
professionalEddy Vluggen2-Mar-15 8:02 
Questioncreating a generic factory class that handles ValueTypes ? Pin
BillWoodruff28-Feb-15 23:36
professionalBillWoodruff28-Feb-15 23:36 
AnswerRe: creating a generic factory class that handles ValueTypes ? Pin
OriginalGriff1-Mar-15 0:11
mveOriginalGriff1-Mar-15 0:11 
GeneralRe: creating a generic factory class that handles ValueTypes ? Pin
BillWoodruff1-Mar-15 1:23
professionalBillWoodruff1-Mar-15 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.