|
thankyou people 4 ur interest
Yes i usually use parameter classes for sql queries.I will use that here after the correct operation of my code.
I have also tried the code of what u suggested but still output is incorerct.Although whenever i execute the query in sql it returns me some rows.
I have also tried with SqlDataReader but DataReader remains null
|
|
|
|
|
1. if your using .net 3.5 then use linq to sql here -> http://www.asp.net/learn/linq-videos/
2. why are you checking wherewer the strQueryString is null or nott why whuld that mather your outputting to dtTableRecords_out the first element of objDataSet.Tables[0] isent that what your going for.
|
|
|
|
|
i have a datagridview that loads a total of 1000 rows from sqlserver. when i click a button to preview the contents of the datagridview to be printed, it only prints 20 rows (those that fit in the datagridview in the form). i want to be able to print ALL the data that is loaded into the datagridview. can someone help me with the codes? thank you..
|
|
|
|
|
You need to write code to handle the print event and render ALL the data, not the current page. The stuff you get for free just prints the current screen.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello,
I am trying to programatically add an Image to a word document. I have managed to do that with the code below. However, I need to insert it into a specific cell in a table that is in the document header. I can insert it into a table in the main body, but cant figure out how to set the range to a cell in a table in the header. Any help will be appreciated.
Thank you.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office;
using Word = Microsoft.Office.Interop.Word;
using Microsoft.Office.Interop.Word;
namespace InsertImageIntoWord
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
object missing = System.Reflection.Missing.Value;
object fileName = @"C:\Form100.doc";
ApplicationClass WordApp = new ApplicationClass();
Document odoc = WordApp.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
WordApp.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekPrimaryHeader;
Range rng = odoc.Tables[1].Cell(1, 3).Range;
rng.InlineShapes.AddPicture(@"C:\Test.jpg", ref missing, ref missing, ref missing);
WordApp.Visible = true;
}
}
}
|
|
|
|
|
Did you get any help. I am facing same issue.
|
|
|
|
|
Hi.
Above code works fine but I want to insert image at the beginning of existing word document.Please provide me the solution.
|
|
|
|
|
ApplicationClass WordApp = new ApplicationClass();
The above code is not working..
I am getting the below error.
Microsoft.Office.lnterop.Word.ApplicationClass cannot be embedded. Use the applicable interface instead.
|
|
|
|
|
Hello,
I searched all over the internet but didn't find a very good answer on this. I know this is a very helpful forum so maybe I will get lucky.
The question is pretty simple : How can I get the position (x,y) of a small image in a large image ? The ideea is that the large image contains the small image, but I want to find out where exactly it is.
I know it can be done by converting the images to bmp and after that going to each pixel at a time and checking if it exists.
Is there another way ?
Can someone help ?
Thanks
PS: The big image is black and white (not monochrome, but only black and white) and the small image is also only black and white.
modified on Saturday, September 19, 2009 6:59 PM
|
|
|
|
|
sodevrom wrote: Is there another way ?
The simplest method to start with is pretty simple. You pretty much get the pixel from the top left corner of the small image, then start scanning the big image, row-by-row, pixel-by-pixel, looking for a pixel of that color. When you find it, then you start getting each pixel in the small image for the rest of the top row and comparing those to the next pixels in the big image. If they match, you go to the next rows and start comparing those pixels, until your done. If not, go back and keep scanning for the top left corn pixel.
|
|
|
|
|
Hello,
I thought that maybe there is a faster way to do this.
Something like convert the image (this is a stupid idea, but something siliar ) to a string and use seomthing like image.indexof ...
Maybe something to do with bytes .
Any ideas are well appreciated
|
|
|
|
|
Which, when you write that method, would do the exact same thing.
Search the Articles for Christian Graus' Image Processing articles for examples on scanning an image quickly.
|
|
|
|
|
Actually you're on the right track. Looking at the images as long strings allows you to do Boyer-Moore String Searching (http://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_string_search_algorithm[^]).
This can be tens to hundreds of times faster than pixel-by-pixel comparisons.
The basic idea is this: Say the small image is length n. You build a dictionary of all the pixel values that occur in the small image. If you look at pixel (n-1) in the larger image, and this pixel is NOT in your dictionary, you can conclude that the smaller image cannot occur at any point in the larger image from position 0 to (n-1).
If n is 1000, you can step through the larger image 1000 times as fast as searching pixel-by-pixel.
One approach is to construct pixel dictionaries for both the small and large image, then find a sequence of pixels in the smaller image that are rare in the larger image. Then search for this sequence in the larger image. Since this sequence has rare pixels, you'll be able to do more Boyer-Moor "jumps", speeding up your processing.
You may want to only look for one row of the smaller image to avoid having to skip pixels to reach the row underneath this in the larger image.
|
|
|
|
|
Here's my method. Maybe someone need. Works quickly.
Point IndexOfImage(Bitmap bmp1, Bitmap bmp2)
{
Point retP = new Point(-1, -1);
int bw = bmp1.Width;
int bh = bmp1.Height;
int bw2 = bmp2.Width;
int bh2 = bmp2.Height;
if ((bw < bw2) || (bh < bh2)) return retP;
Bitmap bmp = new Bitmap(bw2, bh2);
Rectangle rect = new Rectangle(0, 0, bmp1.Width, bmp1.Height);
System.Drawing.Imaging.BitmapData bmpData = bmp1.LockBits(rect, System.Drawing.Imaging.ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
IntPtr ptr = bmpData.Scan0;
int bytes = bmpData.Stride * bmp1.Height;
byte[] rgbValues = new byte[bytes];
System.Runtime.InteropServices.Marshal.Copy(ptr, rgbValues, 0, bytes);
Rectangle rect2 = new Rectangle(0, 0, bmp2.Width, bmp2.Height);
System.Drawing.Imaging.BitmapData bmpData2 = bmp2.LockBits(rect2, System.Drawing.Imaging.ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
IntPtr ptr2 = bmpData2.Scan0;
int bytes2 = bmpData2.Stride * bmp2.Height;
int bm = bytes2;
byte[] rgbValues2 = new byte[bytes2];
System.Runtime.InteropServices.Marshal.Copy(ptr2, rgbValues2, 0, bytes2);
int i = -1, j = 0, i2 = -1, j2 = 0, ind_f = 0;
int f = 0;
int realx, realx2;
i = -1;
j = 0;
for (int y = 0; y < bh - bh2 + 1; y++)
{
j = 0;
realx = 0;
for (int x = 0; x < bw * 3 - bw2 * 3; x++)
{
i++;
j++;
if (j == 4)
{
j = 1;
realx++;
}
if (j == 1)
{
bm = 0;
i2 = -1;
j2 = 0;
int y2 = 0;
realx2 = 0;
f = 0;
while (y2 < bh2)
{
i2++;
j2++;
if (j2 == 4)
{
j2 = 1;
realx2++;
}
if (realx2 == bw2)
{
realx2 = 0;
i2 += bmpData2.Stride - bw2*3;
y2++;
}
if (y2 == bh2) break;
if (j2 == 1)
{
if ((rgbValues[i + (realx2 * 3) + (bmpData.Stride * y2)] == rgbValues2[i2]) && (rgbValues[i + (realx2 * 3) + (bmpData.Stride * y2) + 1] == rgbValues2[i2 + 1]) && (rgbValues[i + (realx2 * 3) + (bmpData.Stride * y2) + 1] == rgbValues2[i2 + 1]))
{
f++;
}
else
break;
}
bm++;
}
if (f == bh2 * bw2)
{
retP = new Point(realx, y);
return retP;
}
}
}
i += bmpData.Stride - bw * 3 + bw2 * 3;
}
System.Runtime.InteropServices.Marshal.Copy(rgbValues2, 0, ptr2, bytes2);
bmp2.UnlockBits(bmpData2);
System.Runtime.InteropServices.Marshal.Copy(rgbValues, 0, ptr, bytes);
bmp1.UnlockBits(bmpData);
return retP;
}
|
|
|
|
|
Hello,
I want to make an easy thing:
if(DOWNKEY is pressed){ do something}
or other keys..
Whats the command to use? How?
Thanks.
|
|
|
|
|
You want the keydown event, I expect. Before that, you should buy a basic winforms book, and perhaps before that a basic C# book, and work through it, so you have a foundation of basic knowledge to build on. For every basic question we answer, there's probably several you never ask. These forums are no substitute for some basic research and book learning.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Well I know the basics, like Arrays, Lists, Stacks, Queue, classes, for while if switch oop windowsforms...
But it looks like I didnt learn the KeyDown even.
I will google it now and see if there is a tut for that.
Thanks for ur answer tho.
EDIT: Found how to do it, pretty easy. Thanks.
|
|
|
|
|
p3rson wrote: Well I know the basics, like Arrays, Lists, Stacks, Queue, classes, for while if switch oop windowsforms...
My point is more that if you're learning them bit by bit with google, you're not going through it in an ordered way. Do you know what object is ? Do you know what methods all objects have ? Do you know what boxing is ? Do you know the differences between classes and structs ?
If you type in the name of a class instance and hit the ., you will get a list of all the methods and events on that object. Events have a lightning bolt icon. That should be the first thing you do if you want to know how to use an object to do something. All objects will have events for things like keyboard, mouse, state changes, etc.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hello Everyone,
I am currently working on a senior project for school and in the process of doing this project I have been designated the person to design the GUI for our project. Basically the reason I am posting here is to ask you of any resources or knowledge I may need for the following thing I am trying to do. I was wondering if one can mount a SD card through serial communication? I am trying to communicate to a micro controller that has the SD card connected to it. Any assistance would be greatly appreciated. Thanks.
tkd
|
|
|
|
|
Hi,
I've never seen or read anything remotely resembling an SD card accessed through a serial port.
Is it the functionality you are after, or is it just an idea for some project?
If your PC doesn't come with a card reader, you could buy one and access the SD files right away, no development involved. Here is one[^] solution, there must be millions like it. Most if not all of them would use USB nowadays.
For a once of, you might even use a digital camera, they often work with an SD card and also allow for USB uploads.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
USB is serial, btw
|
|
|
|
|
Then all computer interfaces are serial, including Ethernet, DVI, and the parallel port.
Luc Pattyn
Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
But is has serial right there in it's name... so it must be so!
(Dude, I'm so screwin' with ya, lol, see my reply to the op)
|
|
|
|
|
<removed useless="" babble=""> I suggest using a usb controller, TI will send you a student sample for free, to go with your mcu, but if you're tinkering with an mcu, you probably know that
Though, if you -really- want to, I would recommend looking at http://msdn.microsoft.com/en-us/library/c8zc5kah(VS.80).aspx[^] The MSDN's Serial Communication Application Sample, which is likely your best resource
|
|
|
|
|
i have a multiline textbox which consists of many different lines of text. i want to select one line of the text with a click of the mouse then to delete it with a button. Afterwhich, the textbox will refresh and align itself properly (For example, all the remaining text move up the empty deleted line. Can anyone advise me on how to go about it or have a sample code which i could follow as i have no idea on how to do this. I'm new to C#.
|
|
|
|
|