|
Looking at your original code you are only getting the date, not the time.
|
|
|
|
|
I am getting like this as well in some rows, 8/31/2017 12:59:00 AM, is there anything I am missing or doing wrong buddy?
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
indian143 wrote: is there anything I am missing or doing wrong Yes, you are not looking closely at your code. You have
(DT_DATE)(SUBSTRING([Date Posted],1,4) + "-" + SUBSTRING([Date Posted],5,2) + "-" + SUBSTRING([Date Posted],7,2))
But how do those substring commands relate to the fields in a string of 8/31/2017 12:59:00 AM ?
|
|
|
|
|
Can't tell if you're writing SQL or C#:
"Sub-stringing" "dates" instead of DATEPART; "casting" instead of Sql CAST or CONVERT.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
Hi Buddy,
I could able to figure it out some how to convert the values into float, date using Data Conversion of SSIS, but there is one small problem I am getting when I convert the Date string that looks like '8/31/2017 12:59:00 AM' into Dt_DbDateTimeStamp or Dt_Date, it is only importing the like this: '8/31/2017 00:00:00 AM'
Can anybody please suggest me what to do to import the full Date time stamp at least up to minutes or seconds if possible.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 5-Oct-17 9:14am.
|
|
|
|
|
Hi,
I am reading an Excel file by using Excel.Interop, its reading all the rows and columns but for a file which has 65536 Rows and 256 Columns, its roughly taking around couple of hrs, I need to finish it within around 10 minutes, is there anything I can do in the below code, any suggestion, code snippet or even link helps me. I have to use only interop no Jet or Ace drivers I can use, here I am putting my code please help me any thing can help - thanks in advance.
static void ReadExcel(String strFileName, string strDelimiter)
{
int RowCount = 0, ColCount = 0;
//Write to text
StreamWriter sw = new StreamWriter(@"C:\Test Files\Test.txt");
String strCell = "";
int col;
Object Opt = Missing.Value;
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application(); //= new Excel.Application();
//Declare Workbook
Microsoft.Office.Interop.Excel.Workbook book;
//Excel.Worksheet sheet;
Microsoft.Office.Interop.Excel.Worksheet xlsSheet;
Microsoft.Office.Interop.Excel.Range oRng;
//Open Spreadsheet
book = app.Workbooks.Open(strFileName, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt, Opt);
//Take the first sheet
xlsSheet = (Microsoft.Office.Interop.Excel.Worksheet)book.Sheets[1];
if (xlsSheet != null)
{
//Read the first cell
oRng = (Microsoft.Office.Interop.Excel.Range)xlsSheet.Cells[1, 1];
ColCount = xlsSheet.Columns.Count;
RowCount = xlsSheet.Rows.Count;
}
for (int row = 0; row < RowCount; row++)
{
strCell = "";
for (col = 0; col < ColCount; col++)
{
oRng = (Microsoft.Office.Interop.Excel.Range)xlsSheet.Cells[row + 1, col + 1];
if (col < ColCount - 1)
{
strCell = strCell + oRng.Text.ToString() + strDelimiter;
}
else
{
strCell = strCell + oRng.Text.ToString();
}
}
//Write to text file
sw.WriteLine(strCell);
}
Console.WriteLine(strCell);
sw.Close();
book.Close(false, false, Missing.Value);
}
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
-- modified 3-Oct-17 18:10pm.
|
|
|
|
|
Office Interop = slow. There's no getting around that.
If you're using Excel 2007 or higher formats, like .xlsx, then you can use the OpenXML or ClosedXML SDK's. They will be much faster processing Excel sheets. The down side is there is a rather learning curve associated with using them.
|
|
|
|
|
Read as a CSV, I can predict runtimes in the seconds; if not milliseconds.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
If you're using Excel 2007 files (*.xlsx ), any of the following will work:
If you need to support Excel 2003 files (*.xls ) as well, you'll need something like NPOI[^].
(There are also commercial toolkits around, but I've never seen the need for them when all of the above libraries are free and open-source.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You need to learn program profiling: Profiling (computer programming) - Wikipedia[^]
With a profiler program, you will spot the parts where the computer spend time.
If you don't have such tool, as simple benchmark and runs with changing some values (number of rows and columns) will give you hints.
You will discover that runtime is linear with row numbers, but that it is not with column numbers.
You will see that runtime turn ugly as columns increase. The problem comes from the way you build the string inside the column loop.
Think about your code, and about the reason you do what you do, is it really needed?
Search if there is another way to things.
Patrice
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
|
|
|
|
|
i have one program.in that n number of boxes.need to arrange the box according to the size.first biggest box is the outer box.that we need to place in (0,0) position.Rest all the boxes i need to arrange inside the box from biggest to smallest.biggest in the bottom.smallest in the top.if the outer box height is more than the inner box arrange near to the bigger box of the bottom.
can anybody help me
|
|
|
|
|
Sounds very much like a homework assignment to me. We don't do homework for you - it's set for a reason, to test what you know, not what a random bunch of strangers on the Internet know. What have you tried so far? What code do you have?
This space for rent
|
|
|
|
|
I've seen a post from Luc Pattyn describing it as a "knapsack problem". Found the thread here[^], and contains a link to wikipedia detailing different sacks and some pseudo-code.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Hi, I am processing Excel files, I need to convert the .xls files that are 32 bit into 64 bit .xlsx files and supply them to the SSIS Packages for Processing. I need to write it in .Net code, can anybody please help me in this regards if its possible or not? I am also searching on google, if you can help me it will save me, as it is needed little urgently. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
They're not 32-/64-bit files. The .xls files are old-style Excel 2003 files, and the .xlsx files are the newer Excel 2007 / OpenXML files.
If you're writing an interactive desktop application which will be run on a computer with Office 2007 or later installed, you could use Interop to convert the files:
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Open(sourceFilePath);
wb.SaveAs(Filename: destinationFilePath, FileFormat: Microsoft.Office.Interop.Excel.XlFileFormat.xlOpenXMLWorkbook);
wb.Close();
app.Quit();
Otherwise, you'll need to use a library which supports both formats - for example, NPOI[^]. It's not trivial, but this StackOverflow answer[^] has an example.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi,
I am getting an issue in my Application that's reading Excel files and Oracle Database, it was working before it started giving problems suddenly.
I am thinking probably the drivers are the issue, but want to know which drivers are installed on the machine.
Can somebody please let me know how can I find the version and mode (like 32 or 64 bit) Oracle and Office Drivers installed on my machine. I am also searching on the google, but if you can help me earlier than that, it would be a great help my friends. Thanks in advance.
Thanks,
Abdul Aleem
"There is already enough hatred in the world lets spread love, compassion and affection."
|
|
|
|
|
I can see you, sitting on the couch, feet on the coffee table, typing this on your phone, while watching tv...
It took more effort to type this message than to go into the Control Panel; Admin; etc.
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
|
|
|
|
|
It is possible that the OP was not expressing himself perfectly! If it was, indeed, the software on his machine (i.e. the one he was sitting in front of) about which he was asking, your response was fairly appropriate. I suspect, however that he is trying more generally to identify the installed Oracle and Office versions on a user's system from within a running Application. I haven't looked into this for Oracle, but I have for Office, and it is highly non-trivial, since Microsoft doesn't keep comprehensible Office version information in any standard location. If that is what he needs, I suggest that he posts back to confirm this, and I will try to offer some suggestions.
|
|
|
|
|
Dim Number1 As String = "2812"
Dim Str, strTemp, strReturn As String
Dim x As Long
Str = "ATDT" & Number1 & "R"
For x = 1 To Len(Str)
strTemp = Hex$(Asc(Mid$(Str, x, 1)))
If Len(strTemp) = 1 Then strTemp = "0" & strTemp & ","
strReturn = strReturn & Space$(1) + "&H" & strTemp
Next x
strReturn = stReturn & " &HD"
Dim Num as integer = Convert.ToInt32(strReturn)
buffer = {Num}
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
Threading.Thread.Sleep(500)
buffer = {&H41, &H54, &H44, &H54, &H32, &H38, &H31, &H32, &H52, &HD}
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
Threading.Thread.Sleep(500)
Next x
modified 1-Sep-17 8:09am.
|
|
|
|
|
Problem 1:
Convert.ToInt32 expects a string containing a single numeric value, and returns a single Integer value.
You are trying to convert a string containing multiple numeric values, and expecting an array of Integer values.
You would need to split the string, and convert each part separately.
Problem 2:
Convert.ToInt32(ByVal value As String)[^] does not allow you to use a Hex prefix. Neither the VB prefix (&H ) nor the C# prefix (0x ) will work.
Instead, you need to remove the prefix and call the overload which accepts the base you want to convert from:
Convert.ToInt32(ByVal value As String, ByVal fromBase As Integer)[^]
(NB: The C# prefix would work with this overload, but the VB.NET prefix won't.)
Dim parts() As String = strReturn.Split(" "c)
Dim buffer() As Integer = Array.ConvertAll(parts, Function(p) Convert.ToInt32(p.Substring(2), 16))
Problem 3:
You're converting the values to Integer , but Write[^] expects an array of Byte values.
It would be much simpler to use the Encoding[^] class to convert the string to a series of bytes:
Dim Number1 As String = "2812"
Dim Str As String = "ATDT" & Number1 & "R" & Chr(&HD)
Dim buffer() As Byte = System.Text.Encoding.ASCII.GetBytes(Str)
frmMain.SerialPort1.Write(buffer, 0, buffer.Length)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
modified 19-Sep-17 7:38am.
|
|
|
|
|
Thanks, I guess I was just over complicating it.
|
|
|
|
|
Richard Deeming wrote: Convert.ToInt32 does not allow you to use a Hex prefix. Neither the VB prefix (&H ) nor the C# prefix (0x ) will work.
Huh?
"If fromBase is 16, you can prefix the number specified by the value parameter with "0x" or "0X"."
Convert.ToInt32 Method (String, Int32) (System)[^]
|
|
|
|
|
Only on the overload that takes the "from base" parameter. That's not the overload the OP was calling.
Convert.ToInt32("2A", 16)
Convert.ToInt32("0x2A", 16)
Convert.ToInt32("&H2A", 16)
Convert.ToInt32("0x2A")
Convert.ToInt32("&H2A")
I'll edit the message to clarify.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
Getting this error.
System.AccessViolationException was unhandled
Message: An unhandled exception of type 'System.AccessViolationException' occurred in AxInterop.ShockwaveFlashObjects.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
When I have Adobe Flash security updates installed.
Using this code
Flash.Movie("movie.swf")
Flash.Play
Then
Flash.LoadMovie(1, "crash.swf") 'Crashes when Adobe Flash is updated, doesn't allow top layer SWF to interact with Movie/base.
To load multiple SWF layers at same time crashes. I'm guessing the security update did something so you can't write layered SWF code to the original SWF's memory. I don't know why this is, but is there any fix or will there be one? This has been like this for about a year now, and it doesn't seem like it'll be addressed.
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at ShockwaveFlashObjects.IShockwaveFlash.LoadMovie(Int32 layer, String url)
at AxShockwaveFlashObjects.AxShockwaveFlash.LoadMovie(Int32 layer, String url)
at AEDab.Form1.ListBox1_SelectedIndexChanged(Object sender, EventArgs e) in C:\Users\UDA\Documents\Visual Studio 2013\Projects\uh\uh\Form1.vb:line 77
at System.Windows.Forms.ListBox.OnSelectedIndexChanged(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
|
|
|
|
|