|
For starters, never concatenate strings to build a SQL command. It leaves you wide open to accidental or deliberate SQL Injection attack which can destroy your entire database. Use Parametrized queries instead.
Then just use your reader object:
while(reader.Read())
{
Console.WriteLine(reader["Arrive_img_ID"]);
Console.WriteLine(reader["Leave_img_ID"]);
}
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I want to import documents from the scanner in my MVC web application and use optical character recognition to fetch the data.
I am not willing to use any expensive libraries like TWAIN, dynamsoft, Atalasoft, LeadTools, Asprise, etc..
I looked for Microsoft OCR, but it seems the library only works for Windows Store Apps.
Please suggest me some good yet free/cheap library for scanning and OCR in MVC web application.
|
|
|
|
|
The server can't access hardware on the client. If you're googling for OCR libraries that can be used with MVC you're not going to find anything.
|
|
|
|
|
You could try Tesseract. A .NET wrapper is available here[^].
/ravi
|
|
|
|
|
Can you provide me with bit more details about Tesseract for .net. Didn't get much documentation about it.
|
|
|
|
|
See this[^] link for instructions.
/ravi
|
|
|
|
|
when i extracted BLOB data from database i can see like this in my word doc.
how to convert it to readable format?
o � 8 A+ ¬ 2
e �
o � ¬ 2
e
o � Cleveland, OH : & + & % / . H F
2
e ( o � �) � o ' �� � �� � @ Garamond - 2 2
� P o � Management Trainee ProgramZ 0 7 0 6 / S /
|
|
|
|
|
That depends on what it is!
If it's a Word document, then save it as a .DOC or .DOCX file, and get Word to open it. Presumably, when you saved the data you also saved a file name with it?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Yes correct..i am saving it as .DOC
when i am opening, it is asking conversion from "Encoding text" and when i select "Unicode" it is displaying like that
|
|
|
|
|
Try an experiment: upload a known-working file, and then save it as a different name. Compare the two and see if there are any differences.
If there are, then you need to start by looking at how you are storing it and make sure that works first.
But...DOC files aren't all Unicode - they can be a binary format, so doing an Unicode conversion is probably going to mess them up.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Chances are that even inside your Word document and this web page there are many things that messed up the format, made it even worse.
The binary object that you captured was indeed an array of bytes containing the data (I won't say it was initially a Word document) with a format to be taken care of while converting back to a valid file. That is why whenever you store a file in the image type (in SQL image is the binary data, not the image you know) you also store the file extension or MIME type (the thing you know as "application/json" etc.). They are used to convert that data back to files.
When you copied the data, it was not of Word format, every file has its own structure that is followed when converting the bytes back to a representation of the file. Word was not able to convert it back to actual representation, in which case it showed you that broken format.
Notice that most of the content, such as those characters were easily mapped and thus they were shown to you, but a few other stuff was not mapped. Simple as that.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Ya correct..few content not mapped and some of the content mapped..tried dfferent options from Word ponit of view..but no luck
|
|
|
|
|
Was the file initially of Word format (.doc or .docx; Rich Text Format is a separate case)?
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
Yes..I am sure..its .DOC only..
|
|
|
|
|
I would recommend that you create the file using the stream (read the binary data using the SELECT) and then convert the stream (of binary data) to a file. In simple words, follow what OriginalGriff said above.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
hi
i know how to work with Keystroke and i know how to send any keboard typing
to any open windows to focus place the cursor on local computer.
i work with GlobalKeyboardHook
now, i need to send some data to open windows on focus place using RDP
for any computer that in my net.
how to do it ? my solution dont work
(i work on C# visual-studio 2010 WinForm)
|
|
|
|
|
What are you trying to do on the remote machine?
SendKeys does not work over RDP and GlobalKeyboardHooks are for capturing keystrokes on the machine it's running on, not for sending to another machine.
|
|
|
|
|
hi i had learn c++ and something about the framework Qt but the problem that the Qt is not used for building apps smartphone like C# or JAVA !!
so do u advice me to leave c++ and Qt and start with C# or JAVA ??
please i need your Advice Thank you
|
|
|
|
|
Pick one place and post there, not in QA, C++, and C#.
Otherwise, you duplicate work and annoy people.
You have this posted in QA, so leave it there.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Don't different people participate in these forums though? There may be folks who only check the C# or say the C++ forums, and others who only check QA. I would think it's alright to cross-post in this situation.
|
|
|
|
|
Indeed, this is true. For a discussion, I would have said that this forum was a far more appropriate choice than QA.
|
|
|
|
|
hello all,
I am creating a list of textbox's dynamically using list and also have added a ok button and created a click_event for the button. But how will i fetch the textbox content that was created dynamically thru the click event of the button. Please see the code below :
public static List<string> InpBox(string title, List<string>prompt, ref string value, int TxtCnt)
{
Form form = new Form();
Button buttonOk = new Button();
Button buttonCancel = new Button();
List<string> inputTexts = new List<string>();
List<textbox> inputTextBoxes = new List<textbox>();
form.AutoSizeMode = AutoSizeMode.GrowAndShrink;
form.AutoSize = true;
form.Padding = new Padding(0, 0, 20, 20);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
form.Text = title;
for (int i = 1; i <= TxtCnt; i++)
{
Label labelInput = new Label();
TextBox textBoxNewInput = new TextBox();
labelInput.Text = prompt[i-1];
labelInput.Location = new Point(0, (i * 30));
labelInput.AutoSize = true;
System.Drawing.SizeF sizeF = new System.Drawing.SizeF();
System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(new System.Drawing.Bitmap(1, 1));
sizeF = graphics.MeasureString(labelInput.Text, new System.Drawing.Font("Arial,Verdana,Helvetica,sans-serif", 10, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point));
int maxTextWidthinPixel = Convert.ToInt32(sizeF.Width);
textBoxNewInput.Location = new Point(maxTextWidthinPixel - 20, labelInput.Top - 3);
textBoxNewInput.Width = 372;
inputTextBoxes.Add(textBoxNewInput);
form.Controls.Add(labelInput);
form.Controls.Add(textBoxNewInput);
}
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.Location = new Point(form.Width / 2 - buttonOk.Width / 2, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
buttonCancel.Location = new Point((form.Width / 2 + buttonOk.Width / 2)+10, inputTextBoxes[inputTextBoxes.Count - 1].Bottom + 20);
form.Controls.Add(buttonOk);
form.Controls.Add(buttonCancel);
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonOk.Click += new EventHandler(buttonOk_Click);
form.ClientSize = new Size(396, 135);
DialogResult dialogResult = form.ShowDialog();
return inputTexts;
}
assistance needed. Thanks in advance
Antony,
ansonel@gmail.com
|
|
|
|
|
Since you create a number of textboxes (which is probably a poor idea - have a look at a DataGridView or similar instead, it does most of the work for you) you will have to search for them (or use the inputTextBoxes collection you added them to).
Searching is relatively simple - they are in the form Controls array along with all the others - but I'd just look in your collection! Just move it to a private class level variable and access it in your Click event handler.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Hi Antony, and welcome to CodeProject !
I think you are using a strategy that is far too complex here.
Why not create one UserControl that has both a Label, and TextBox; then create multiple instances of that UserControl as needed ?
In the UserControl try setting the AutoSize property to 'true on the Label, and its Dock property to 'Left; set the TextBox 'Dock property to 'Fill. That way you can avoid the business your doing now to measure the width of the string.
Within the UserControl, you can expose the TextBox by creating a Public property that references the contents of the TextBox, or exposing the TextBox TextChanged Event.
I like to use "lazy-load" techniques, so I might write something like this in the UserControl:
private string _currentText;
public string CurrentText
{
set
{
_currentText = value;
textBox1.Text = value;
}
get { return textBox1.Text; }
}
As you create the instances of the UserControl, you can, at the same time, create a generic List or Array to store either the TextBox itself or its Text data. Then, when your Button is pressed, you can just iterate over the reference to stored values, or data, and get what you need.
You could use Linq to make an IEnumerable<string>, containing all the strings in all the TextBoxes, or whatever else you need. Assuming I used the string Property shown above, and I kept a List named 'LblTbList<LabelAndTextUserControl> of the Custom User Controls in the Form where they created"
public IEnumerable<string> GetData()
{
return LblTbList.Select(itm => itm.CurrentText);
} That function would return an IEnumerable containing all the strings in all the TextBoxes.
And the code in the context that "consumes" the data (the code your showing using 'ShowDialog) can then iterate over that, or whatever.
private void button2_Click(object sender, EventArgs e)
{
foreach (string txt in YourTestForm.GetData().ToList())
{
Console.WriteLine(txt);
}
} cheers, Bill
«I want to stay as close to the edge as I can without going over. Out on the edge you see all kinds of things you can't see from the center» Kurt Vonnegut.
|
|
|
|
|
I have this code:
TimelineStart = new DateTime(2015, 08, 11, 10, 00, 00);
TimelineEnd = new DateTime(2015, 08, 14, 20, 00, 00);
TotalHours = (TimelineEnd - TimelineStart).TotalHours;
Day 1 = 10 Hours
Day 2 = 24 Hours
Day 3 = 24 Hours
Day 4 = 20 Hours
TOTAL 78 Hours
The TimeSpan is showing TotalHours = 82.
What's wrong here?
If it's not broken, fix it until it is
|
|
|
|