|
This information was indeed very useful...
Thanx
rome'
|
|
|
|
|
How about using settings - either application, or user if they change?
|
|
|
|
|
Well friend thanks for your reply
I am using application settings....its just that i wanted to put all the settings into separate variables and have them accessible from a class...
right now what the programmers in my team have happened to do is the following
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(true);
objMdiForm = new MdiForm();
Application.Run(objMdiForm);
the properties are defined in MdiForm and they are being accessed from the instance objMdiform
i found that messy and i wanted to put them in a class..
Anyway thanks a lot for your insight...
Take Care
rome'
|
|
|
|
|
singleton approach sound's good .
While maintaining the application Static is nightmare
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
Hi,
I have a problem with an oracle DB which is installed with an utf8-characterset. I build a form in VS2005 where the user type in a SQL-selectstatement and the form executes it and displays the result. Everything works fine with a singlebytecharcterset.
For example:
String sqltext = "Select artext from tbl_ar";
DataTable schTable;
OracleDataReader rdr = null;
OracleCommand cmd = new OracleCommand (sqltext, OracleConnection, OracleTransaction);
rdr = cmd.ExecuteReader(CommandBehavior.KeyInfo);
schTable = rdr.GetSchemaTable();
DataRow fldDescr = schTable.Rows[0];
int len = (int) fldDescr[2];
In the database with the utf8-characterset the variable len hat the value 0f 90 instead of 30. Is there a way to get the correct result ?
Thanks in advanced
Stofel
|
|
|
|
|
Hi,
Check that your character set is compatible at client side (HKEY_LOCAL_MACHINE\Software\Oracle....)
Mika
|
|
|
|
|
We have developed winform application in C#. Here when user logout we are storing logout time in database. Right now we have a code written in formclosing event for updating logout time. But if any error occurs while application is running / if we kill process from windows task manager then its not updating logout time. So please can any one suggest whats the best way to update logout time in Database. Because next time when user enters into application we are displaying message that "you are already logged in (System Name)system. Please logout!" . So if application is closed and logout time is not saved then user will get this message. So we want to update even if any exception in app / closed intentionally from task manager. Is there any event to handle this???
Please reply its very urgent.....
Rashmi.M.K
|
|
|
|
|
I don’t think that this (killing the application from Task Manager) can be handled with in the application itself.
And in fact, there can be n number of scenarios like this:
• What if I Shut Down my computer.
• What if there is hard disk crash.
|
|
|
|
|
Solution
1. Create a timer thread, that will send message if you dont get message application is dead .
2. Trace the Process of the application , if you dont find the process
the application is dead ( this has to be done from other process <new thread="" wont="" work="">, so u have 2 process )
Vikas Amin
My First Article on CP" Virtual Serial Port "[^]
modified on Thursday, July 24, 2008 5:33 PM
|
|
|
|
|
thank u for good suggestion...
Rashmi.M.K
|
|
|
|
|
Dear All!!!
Please help me to resolve this error from the code i m posting here...my image is stored in ms-access database
as OLE object under the field name img_stream. I get "Invalid parameter used" error at "bmp = new Bitmap(ms)"
private void Page_Load(object sender, System.EventArgs e)
{
myAccessConnection = new OleDbConnection(connStr);
openAccessConnection();
OleDbCommand myCommand = new OleDbCommand("select img_stream from tblImg where img_id=4", myAccessConnection);
OleDbDataReader reader = myCommand.ExecuteReader();
if(reader.Read())
{
MemoryStream ms = new MemoryStream();
Response.ContentType = "image/jpeg";
byte[] imageContent = (byte[])(reader["img_stream"]);
ms.Write(imageContent, 0, imageContent.Length);
Bitmap bmp;
bmp = new Bitmap(ms);
bmp.Save(Response.OutputStream, ImageFormat.Jpeg);
ms.Close();
closeAccessConnection();
}
else
{
closeAccessConnection();
}
}
String connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + HttpContext.Current.Server.MapPath("App_Data/db1.mdb");
OleDbConnection myAccessConnection;
protected void openAccessConnection()
{
if (myAccessConnection.State == ConnectionState.Closed)
{
myAccessConnection.Open();
}
}
protected void closeAccessConnection()
{
if (myAccessConnection.State == ConnectionState.Open)
{
myAccessConnection.Close();
}
}
Please help me out..This error is annoying me since last week and no solution yet!!
Thankyou!!!
|
|
|
|
|
Try this
{
byte[] imageContent = (byte[])(reader["img_stream"]);
MemoryStream ms = new MemoryStream(imageContent );
Bitmap bmp;
bmp = new Bitmap(ms);
bmp.Save(ms, ImageFormat.Jpeg);
closeAccessConnection();
}
Rashmi.M.K
|
|
|
|
|
Dear Sender!!!My error is still there..I have tried your instruction but no way out!!Please help...
|
|
|
|
|
Try this.. its working fine here.. i have executed your code its working.
{
byte[] imageContent = (byte[])(reader["img_stream"]);
MemoryStream ms = new MemoryStream(imageContent );
Image bmp = new Bitmap(ms);
bmp.Save(ms, ImageFormat.Jpeg);
closeAccessConnection();
}
Rashmi.M.K
|
|
|
|
|
I have tried your instruction but now i m getting following errors:
1. 'Image' is an ambiguous reference
2. The type or namespace name 'bmp' could not be found (are you missing a using directive or an assembly reference?)
I m using following namespaces:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Drawing.Imaging;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.IO;
and i've used no image control...Please help!!!
|
|
|
|
|
u are reading image from Database. After this where do you want to display? what exactly you want to do?
Rashmi.M.K
|
|
|
|
|
Yes i m reading image from database and i want to display that on web page.
|
|
|
|
|
hi guys! I have a problem with the sql exception what I am getting while I am trying to upload a PDF file in a database. I have set the field for the document to be varbinary(MAX) so I will not have any problems with the size, but the exception says that my file is over the limit and I am getting this message when I am trying to update the table, at the last line of the code. Here is the code:
SqlConnection conn = new SqlConnection(some connection);
conn.Open();
SqlDataAdapter da = new SqlDataAdapter("Select * FROM Table", conn);
SqlCommandBuilder MyCB = new SqlCommandBuilder(da);
DataSet ds = new DataSet("Table");
da.MissingSchemaAction = MissingSchemaAction.AddWithKey;
FileStream fs = new FileStream(@"C:\\PDFdocument"+"\\" + PDF, FileMode.OpenOrCreate, FileAccess.Read);
byte[] myData = new byte[fs.Length];
fs.Read(myData, 0, System.Convert.ToInt32(fs.Length));
fs.Close();
da.Fill(ds, "Table");
DataRow myRow;
myRow = ds.Tables["Table"].NewRow();
myRow["Document"] = myData;
myRow["ID"] = fileID;
ds.Tables["Table"].Rows.Add(myRow);
da.Update(ds, "Table");
how I can solve this issue? Thx ahead
|
|
|
|
|
|
i am trying to take under control of changing datarows. when there is a change i want to ask user whether he/she wants to save changes or discard changes. to accomplish this i am using rowchanged event
private void Form1_Load(object sender, EventArgs e)
{
this.kisiTableAdapter.Fill(this.denekDataSet.Kisi);
denekDataSet.Kisi.KisiRowChanged += new denekDataSet.KisiRowChangeEventHandler(Kisi_KisiRowChanged);
}
void Kisi_KisiRowChanged(object sender, denekDataSet.KisiRowChangeEvent e)
{
DataRowAction drc = e.Action;
if (drc == DataRowAction.Change)
{
DialogResult dr = MessageBox.Show("do you want to save changes!", "warning", MessageBoxButtons.YesNo);
if (dr == DialogResult.No)
{
e.Row.RejectChanges();
}
}
}
when there is a change this event works. and if user choice is "no" it works perfectly. but dialog result is "yes", there is a problem appears. changes are not apply to the database(restart the program). everything same as before the change action.
i tried different ways but it causes different errors(exception).
void Kisi_KisiRowChanged(object sender, denekDataSet.KisiRowChangeEvent e)
{
DataRowAction drc = e.Action;
if (drc == DataRowAction.Change)
{
DialogResult dr = MessageBox.Show("do you want to save changes!", "warning", MessageBoxButtons.YesNo);
if (dr == DialogResult.No)
{
e.Row.RejectChanges();
}else
{
kisiTableAdapter.Update(denekDataSet.Kisi);
}
}
}
after changing it calls many times messagebox for asking choice then produces InvalidOperationException and stops.
how can i solve this problem, it makes me anger and tired.
please help me , or show me a different way.
my intention is tracking changes and asking right question.
thanks for interests
::CTBRS::
|
|
|
|
|
there is not any answer, please help me.
::CTBRS::
|
|
|
|
|
Hey Everyone,
I am doing a VB6 to C# conversion and everything was going smoothly until I realized that I needed to call a Fortran 77 (.for) .dll inside my code. I have looked through everything I have found using Google and have still been unable to get it to successfully work. Currently the following call works about 75% of the time, but the other 25% of the time my program just calls the .dll and then it simply exits; no error/exception occurs, it just quits without executing anymore code. As you can see I have tried multiple ways to catch/generate error messages. I have no Fortran experience and I was told to leave the Fortran code alone, since it has been around and working since the 70’s.
From what I can tell the Fortran code only has one subroutine. I have included the header/parameters below:
SUBROUTINE FORTRANCALLA(INPUTL, TABLEL, NAMEL2, COMMAL, LOADL)
EXTERNAL F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,F20
!DEC$ ATTRIBUTES DLLEXPORT :: FORTRANCALLA
!DEC$ ATTRIBUTES STDCALL, ALIAS: 'FORTRANCALLA' :: FORTRANCALLA
!DEC$ ATTRIBUTES REFERENCE :: INPUTL
!DEC$ ATTRIBUTES REFERENCE :: TABLEL
!DEC$ ATTRIBUTES REFERENCE :: NAMEL2
!DEC$ ATTRIBUTES REFERENCE :: COMMAL
!DEC$ ATTRIBUTES REFERENCE :: LOADL
CHARACTER(80), INTENT(IN) :: INPUTL
CHARACTER(80), INTENT(IN) :: TABLEL
CHARACTER(80), INTENT(IN) :: NAMEL2
CHARACTER(4), INTENT(IN) :: COMMAL
CHARACTER(80), INTENT(IN) :: LOADL
It appears C++ was used to wrap the .for file and generate a .dll which was called in the VB6 program using the following code:
Call Fortran.FORTRANCALLA(infilecalc, tablecalc, destination2, format, loadcond)
Public Declare Sub FORTRANCALLA Lib "Name.dll" _
(ByVal INPUTL As String, ByVal TABLEL As String, ByVal NAMEL2 As String, ByVal COMMAL As String, ByVal LOADL As String)
It appears that the VB6 program also has problems with the call, but not as frequently. However, it also handles the failed .dll call much better and does not crash. If possible I would just like my program not to fatally crash.
Here is the code I am currently working with and I am calling the exact same .dll that is currently being used in the VB6 version:
static class Fortran
{
[DllImport("Name.dll")]
private static extern bool FORTRANCALLA(
StringBuilder infilecalc,
StringBuilder tablecalc,
StringBuilder destination2,
StringBuilder format,
StringBuilder loadcond);
public static void Calculate(string infilecalc, string tablecalc, string destination2, string format, string loadcond)
{
string tempOutputPath = FileMod.GetTemporaryDirectory() + "NameTemp.tmp";
StringBuilder bldrInFileCalc = new StringBuilder(infilecalc, 80);
StringBuilder bldrTableCalc = new StringBuilder(tablecalc, 80);
StringBuilder bldrDestination2 = new StringBuilder(tempOutputPath, 80);
StringBuilder bldrFormat = new StringBuilder(format, 4);
StringBuilder bldrLoadCond = new StringBuilder(loadcond, 80);
try
{
if (!FORTRANCALLA(bldrInFileCalc, bldrTableCalc, bldrDestination2, bldrFormat, bldrLoadCond))
MessageBox.Show(new System.ComponentModel.Win32Exception().ToString());
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
//FORTRANCALLA(bldrInFileCalc, bldrTableCalc, bldrDestination2, bldrFormat, bldrLoadCond);
File.Copy(tempOutputPath, destination2, true);
File.Delete(tempOutputPath);
}
}
Right now I cannot find a pattern to the crashes. I could work with the same files, making identical calls to the .dll, and sometimes it works sometimes it doesn't. At first I thought it was something to do with memory allocation, but I don't think that is the case because sometimes it crashes on the first call. Sometimes it only crashes once, sometimes it crashes multiple uses in a row, and sometimes you can make many calls before it starts crashing again.
Does anyone have any ideas? Because I am officially out of ideas...
Thanks,
Nitsua
|
|
|
|
|
Hey guys, what up?
Kinda new to the message board. Hope I'm welcome
I have this problem with a web service; I'm writing a library which hosts a web service which holds an event as a member. Now I want to be able to add a delegate to that event from the library, which is of course not really possible through a web service method since a delegate is kinda like a function pointer.
Someone mentioned the possibility of using named pipes or some other kind of IPC. Does anyone know of such a solution? Can anyone here point me to an example of such implementation?
Thanks in advance,
LZ
|
|
|
|
|
Not sure how much this helps but you might be able to use reflection to achieve something similar? For example instead of storing a delegate, store the class & method name in a string, then use refelction to invoke...
Possibly not what you are looking for, but it might be an approach to consider if you don't get any other suggestions
Hope this helps,
Chris
|
|
|
|
|
I think reflection might help me out.. but I'm looking for a more elegant solution from WCF.
Does anyone know of such?
|
|
|
|
|