|
Ok I set all exceptions around to break the app. It doesn't seem to work. But then I added this :
int j = 0;
int i = 3 / j;
and I had the usual behaviour with line "int i = 3 / j;" highlighted and the relevant exception display.
code is something like :
[DllImport("AVICAP32.dll")]
public static extern bool capGetDriverDescriptionA(
short wDriver,
string lpszName,
int cbName,
string lpszVer,
int cbVer
);
bool bReturn;
bReturn = MyAppCam.Capture.capGetDriverDescriptionA(x,strName,100,strVer,100);
I know that code is stopping on "bReturn = MyAppCam.Capture.capGetDriverDescriptionA ... "
Regards
Roberto
|
|
|
|
|
private void fnLoadSignature()
{
try
{
SqlConnection con = new SqlConnection(conString);
con.Open();
string sql = "SELECT SignatureOfMember FROM CIF WHERE CIFKey = '" + txtcifkey.Text + "'";
cmd = new SqlCommand(sql, con);
object value = cmd.ExecuteScalar();
byte[] data = (byte[])cmd.ExecuteScalar();
MemoryStream strm = new MemoryStream();
strm.Write(data, 0, data.Length);
strm.Position = 0;
System.Drawing.Image img = System.Drawing.Image.FromStream(strm);
BitmapImage bi = new BitmapImage();
bi.BeginInit();
MemoryStream ms = new MemoryStream();
img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
ms.Seek(0, SeekOrigin.Begin);
bi.StreamSource = ms;
error is her------ bi = SigPics.Cursor;
bi.EndInit();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
|
|
|
|
|
You never described what you mean by "load signature pad" and your code says there's an exception being thrown but you never say what that exception is.
With the complete lack of information you provided, the only thing anyone can tell you is to cal the support line of the manufacturer of the pad you're using.
|
|
|
|
|
And to add to what Dave said: 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.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Relevant xkcd: Exploits of a Mom
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
|
You're creating an empty stream, loading an image from that. Then you create a new stream, and save the image there that was created from the empty stream.
Google for "load image from database WPF"
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
i have data and chart in excel work sheet which i need to copy at run time from excel to power point slides.
i have a code which is working fine but the code only can copy chart data to excel sheet not range data.
please see the scree shot of my excel. so anyone can get idea how data is there in my work sheet which i need to copy to power point slide programmatically. enter image description here
screen shot url....please see it. [screen shot url]
here is code which i am using to copy range data and chart data to power point dynamically.
private void Form1_Load(object sender, EventArgs e)
{
pptNS.ApplicationClass powerpointApplication = null;
pptNS.Presentation pptPresentation = null;
pptNS.Slide pptSlide = null;
pptNS.ShapeRange shapeRange = null;
xlNS.ApplicationClass excelApplication = null;
xlNS.Workbook excelWorkBook = null;
xlNS.Worksheet targetSheet = null;
xlNS.ChartObjects chartObjects = null;
xlNS.ChartObject existingChartObject = null;
xlNS.Range destRange = null;
string paramPresentationPath = @"D:\test\Chart Slide.pptx";
string paramWorkbookPath = @"D:\test\MyExcelData.xlsx";
object paramMissing = Type.Missing;
try
{
powerpointApplication = new pptNS.ApplicationClass();
excelApplication = new xlNS.ApplicationClass();
excelWorkBook = excelApplication.Workbooks.Open(paramWorkbookPath,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing, paramMissing,
paramMissing, paramMissing);
targetSheet =
(xlNS.Worksheet)(excelWorkBook.Worksheets["Spain"]);
chartObjects =
(xlNS.ChartObjects)(targetSheet.ChartObjects(paramMissing));
pptPresentation = powerpointApplication.Presentations.Add(
Microsoft.Office.Core.MsoTriState.msoTrue);
pptSlide =
pptPresentation.Slides.Add(1, pptNS.PpSlideLayout.ppLayoutBlank);
destRange = targetSheet.get_Range("A1:B15");
destRange.Copy();
shapeRange = pptSlide.Shapes.Paste();
shapeRange.Left = 60;
shapeRange.Top = 100;
existingChartObject =(xlNS.ChartObject)(chartObjects.Item(1));
existingChartObject.Copy();
shapeRange = pptSlide.Shapes.Paste();
shapeRange.Left = 90;
@shapeRange.Top = 100;
pptPresentation.SaveAs(paramPresentationPath,
pptNS.PpSaveAsFileType.ppSaveAsOpenXMLPresentation,
Microsoft.Office.Core.MsoTriState.msoTrue);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
finally
{
shapeRange = null;
pptSlide = null;
if (pptPresentation != null)
{
pptPresentation.Close();
pptPresentation = null;
}
if (powerpointApplication != null)
{
powerpointApplication.Quit();
powerpointApplication = null;
}
targetSheet = null;
chartObjects = null;
existingChartObject = null;
if (excelWorkBook != null)
{
excelWorkBook.Close(false, paramMissing, paramMissing);
excelWorkBook = null;
}
if (excelApplication != null)
{
excelApplication.Quit();
excelApplication = null;
}
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
please see my code and tell me what to rectify in my code as a result cell range and chart both i can copy to power point slides.
thanks
tbhattacharjee
|
|
|
|
|
What you should do is find out how to do it manually, and once you know nomenclature, you'll know how to google how to do it in code.
Here's a place to start:
Import data from Excel into PowerPoint - PowerPoint
".45 ACP - because shooting twice is just silly" - JSOP, 2010
- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I tried this query in sql.But getting errors like
'The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.'
<pre lang="SQL"> declare cur cursor for Select Table_Name From INFORMATION_SCHEMA.COLUMNS Where column_name = 'INV_DATE'
declare @tablename nvarchar(max)
declare @sqlstring nvarchar(max)
open cur
fetch next from cur into @tablename
while @@fetch_status=0
begin
--print @tablename
set @sqlstring = 'update '+@tablename+' SET INV_DATE = CONVERT(varchar(10),INV_DATE,105)'
exec sp_executesql @sqlstring
fetch next from cur into @tablename
end
close cur
deallocate cur
Please suggest me a solution
current format:2016-03-31 00:00:00.000
Required Format:31-03-2016
DataType:DateTime
|
|
|
|
|
This isn't related to C#, so it's in the wrong place.
But it's a rookie mistake, and I'll answer it as a result.
There is but one solution: change your database.
Never store dates in NVARCHAR columns - always use DATETIME or DATE instead.
If you use the wrong column datatype it's easy to set up, and lazy to get the user data into - but it always gives total nightmares after that - because the data in your DB is not valid, or is not in a consistent format, or is in a different format from that which SQL expects.
Think about it: 10/11/12 is a valid date. But is it 10th Nov 2012, 11th Oct 2012, 12th Nov 2010, or some other value entirely? The only time you can tell is when the user inputs the value, and you use his culture to convert it to a DateTime value - as soon as it arrives in the DB it's too late because you no longer have any idea what date format he used: it could be US: MM/DD/YY, European: DD/MM/YY, or ISO / Japanese YY/MM/DD - and you don't even know that the user is using the same calendar as you so the year could be well different (the Hijri date today is Jumada Al-Awwal 3, 1438)! Or even that he didn't enter "hello, my name is Jackie" which isn't even close to a date.
So when you try to convert it to a date at a later time you are almost guaranteed to get errors because the SQL server will try to convert it using it's culture - and generally you don't even know what culture the server is set to!
Always use appropriate data types - it may be easier for your code to slam in NVARCHAR all the time, but it wastes huge amounts of effort later fixing up the holes it leaves.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
I tried to convert in single table also containing date format in datetime as 2016-03-31 00:00:00.000.
update invINVOICE set INV_DATE =convert(datetime,convert(datetime,INV_DATE ,(105)))
But still got the same error while running the query.
I already written script for database to convert all the columns to datetime with a format '2016-03-31 00:00:00.000'
Now they want only date format containing dd-mm-yyyy.
Please suggest me solution this time.
|
|
|
|
|
You can't. DATETIME fields don't have a format - they are stored as a number of tick since a preset point in time (for SQL Server, that's "ticks since Jan 1st 1753") so quite what you expect two datetime conversions to do I'm not quite sure.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Everything @OriginalGriff has said but perhaps use Date instead of DateTime . Anything else should be done in the presentation layer.
|
|
|
|
|
TarunKumarSusarapu wrote: Now they want only date format containing dd-mm-yyyy.
Store the values in a datetime , datetime2 or date column. That will store the actual date value, without any associated formatting.
Date and Time Types[^]
Any formatting of the value should be done when you display the date values in your application or report.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I tried to copy data and changing to DateTime using temp field.But also getting the same error.
alter table GL add GL_DATE1 datetime null
update GL set GL_DATE=convert(datetime,GL_DATE,104)
update GL set GL_DATE1=GL_DATE
alter table GL drop column GL_DATE
SP_RENAME 'GL.GL_DATE1','GL_DATE','column'
please give me the advice to copy data from one field to another field using the temp table.
|
|
|
|
|
You need to take this question over to the database forum. You started off by asking a SQL question here and now you're asking another SQL question.
This space for rent
|
|
|
|
|
Ok Thank you.I will change the message board. 
|
|
|
|
|
I'm creating some very large images in .net and i'm using JPEG compression to get the file size down. However, if the image exceeds 65,000(ish) pixels in either width or height, I can no longer use jpeg compression. Is there a max dimensions limit for JPEG?
the exception being thrown is:
System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
the code that is saving the image:
public static void SaveImage(ref Bitmap b, string fName)
{
long quailty = 75;
ImageCodecInfo jpgEncoder = getEncoder(ImageFormat.Jpeg);
Encoder myEncoder = Encoder.Quality;
using (EncoderParameters myEncoderParameters = new EncoderParameters(1))
{
using (EncoderParameter myEncoderParameter = new EncoderParameter(myEncoder, quailty))
{
myEncoderParameters.Param[0] = myEncoderParameter;
b.Save(fName, jpgEncoder, myEncoderParameters);
}
}
}
in the case of the above exception the image is 2,000x100,000 the magic number seems to be in the 65k range, both width and height. Like, I can do 4,000x55,000 but not 2x70000.
|
|
|
|
|
|
Hello. I've tried that, with WritableBitmap and run into the same problem. Raw saves fine, jpeg throw the exception.
|
|
|
|
|
So it also a JPEG limitation as found by Griff.
I would suggest too to use PNG or TIFF instead. They are lossless and allow you to reload the same image which would not happen with JPEG.
|
|
|
|
|
A very quick google says it's a JPG limitiation: Quote: The theoretical maximum of a jpeg image is 65,535 x 65,535 (width x height). This is because the fields containing the height and widths is a word (2 bytes wide, or 16 bits). Any limitation below that, I presume is software limitation, not jpeg standard.
Have you considered PNG format? It is readily interpreted by most browsers and software on most operating systems and it allows theoretical 4,294,967,295 x 4,294,967,295.
(How big (in pixels) can a jpg image file be - Photo.net Digital Darkroom Forum[^])
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
Why would you need an image that big, and why can't it be solved with several smaller images representing the same data?
It would still contain the same data, just not have the limitation that it needs to be read as a single entity.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
The function of the tool is to load the file handling.meta and display the values of each parameters present in the file (handling.meta) for within each TexBox of the interface of the tool. So when a value (number) is edited in this TexBox will be saved manually by pressing the "Save" or "Save As" button.
With the following features:
* Open, save and save as...
* Interface localization
* Auto/manual application update
among others.
Example of a handling.meta file editing tool similar to the one I want to create:
GTA V Handling Editor - GTA5-Mods.com[^]
Soon, I'll give you more details about it.
|
|
|
|
|