|
Ed K wrote:
To keep it around you will need to either put it into session, put it into the page cache, or serialize it somewhere else and bring it back when needed.
I ended making the objects static, and placed them in the Global class, this seems to work fine...not sure if this OK, but things look like its working like it should. I'll play some more after some needed sleep.
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Aalst wrote:
error CS0019: Operator '|=' cannot be applied to operands of type 'bool' and 'int'error CS0019: Operator '|' cannot be applied to operands of type 'bool' and 'int'error CS0030: Cannot convert type 'int' to 'bool'error CS0030: Cannot convert type 'byte' to 'bool'error CS0030: Cannot convert type 'bool' to 'byte'
int | int //yes
byte | byte //yes
bool | bool //yes
(int)byte| int //yes
int | bool //no
byte | int //no
The type must be the same
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
I double checked my testing and yes of the same type seems to work. I had an error in the test. A little annoying but better than I thought it was.
Thanks for the correction.
Can you Riddle Me This leppie... Why can't I cast an int or byte to a bool? if it is 0 it would become false, anything else would be true.
Thanks again... sorry for the invalid grip.
Aalst
Coding is a way of life. It's in the air we breath. It pumps through our vines. Without it we soon crumble to dust. - Rodney S. Foley (a.k.a. Aalst)
|
|
|
|
|
Aalst wrote:
Can you Riddle Me This leppie... Why can't I cast an int or byte to a bool? if it is 0 it would become false, anything else would be true.
Then the Convert class would be of not much use
O 5AM must get some sleep
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Good. I didn't know about this class. However, doesn't seem silly to have a whole class that does the work that should be done by a simple cast? Or is this have something to do with .NET and it's multi-language support and not all languages support casting or something like that.
Again thanks for the class info.
Coding is a way of life. It's in the air we breath. It pumps through our vines. Without it we soon crumble to dust. - Rodney S. Foley
|
|
|
|
|
The C# designers purposely designed it this way to prevent errors like...
if (a=0) {} instead of if (a==0) {}
Anyway you can just explicitly write out the ==0.
|
|
|
|
|
I have several string and decimal values that I have to enter into my table through an sql statement. I have one problem. When one of my date fields is null, the table automatically enters the default 1/1/1900. I need to find another way around this. That field needs to stay blank if it is originally blank.
what my code looks like:
string connstr = "my connection to db";
string sSQLCommand = "INSERT INTO t340(cmd_dsg,trns_cd,proc_act_cd,inp_act_cd," + "blk_tkt_no,blk_tkt_dt,seq_no,updt_cd,jono,eor,comt_ref_no,oblg_ref_no_spiin,cost_cen_mgr,docu_dt,act_amt,wi_fed_govt_cd,oblg_stat_cd,oblg_expir_dt,jv_no,oblg_ty_cd,amd_no,qty,wt_lbs,hrs,nomenclature,clin,acrn,mod_no,subjono,ifs_docu_no,lbr_pay_pd_no,prod_ind,reject_cd,correction_cd,load_date)" +
"VALUES('" + cmd_dsg + "','" + trns_cd + "','" + proc_act_cd + "','" + inp_act_cd + "','" + blk_tkt_no + "','" + blk_tkt_dt + "','" + seq_no + "','" + updt_cd + "','" + jono + "','" + eor + "','" + comt_ref_no + "','" + oblg_ref_no_spiin + "','" + cost_cen_mgr + "','" + docu_dt + "'," + act_amt + ",'" + wi_fed_govt_cd + "','" + oblg_stat_cd + "','" + oblg_expir_dt + "','" + jv_no + "','" + oblg_ty_cd + "','" + amd_no + "'," + qty + "," + wt_lbs + "," + hrs + ",'" + nomenclature + "','" + clin + "','" + acrn + "','" + mod_no + "','" + subjono + "','" + ifs_docu_no + "','" + lbr_pay_pd_no + "','" + prod_ind + "','" + reject_cd + "','" + correction_cd + "','" + ldate + "');";
//Create the command object
SqlConnection myConnection = new SqlConnection(connstr);
SqlCommand cmdAdder = new SqlCommand(sSQLCommand, myConnection);
myConnection.Open();
int nNoAdded = cmdAdder.ExecuteNonQuery();
myConnection.Close();
Everything else works. I need to know if there is another way to insert each value and to be able to use an if statement for when the field is blank. I was able to do this in VB but I am having to convert this program.
this is what the VB looked like:
qstr = "Select * from t340 where cmd_dsg = '1111111111111'"
Set temprec = New ADODB.Recordset
temprec.CursorType = adOpenDynamic
temprec.CursorLocation = adUseClient
temprec.Open qstr, cnn1, adOpenKeyset, adLockOptimistic, adCmdText
temprec.AddNew
temprec!cmd_dsg = cmd_dsg
temprec!trns_cd = trns_cd
temprec!proc_act_cd = proc_act_cd
temprec!inp_act_cd = inp_act_cd
temprec!blk_tkt_no = blk_tkt_no
If blk_tkt_dt <> "" Then
temprec!blk_tkt_dt = blk_tkt_dt
End If
temprec!seq_no = seq_no
temprec!updt_cd = updt_cd
temprec!jono = jono
temprec!eor = eor
temprec!comt_ref_no = comt_ref_no
temprec!oblg_ref_no_spiin = oblg_ref_no_spiin
temprec!cost_cen_mgr = cost_cen_mgr
If docu_dt <> "" Then
temprec!docu_dt = docu_dt
End If
temprec!act_amt = act_amt
temprec!wi_fed_govt_cd = wi_fed_govt_cd
temprec!oblg_stat_cd = oblg_stat_cd
If oblg_expir_dt <> "" Then
temprec!oblg_expir_dt = oblg_expir_dt
End If
temprec!jv_no = jv_no
temprec!oblg_ty_cd = oblg_ty_cd
temprec!amd_no = amd_no
temprec!qty = qty
temprec!wt_lbs = wt_lbs
temprec!hrs = hrs
temprec!nomenclature = nomenclature
temprec!clin = clin
temprec!acrn = acrn
temprec!mod_no = mod_no
temprec!subjono = subjono
temprec!ifs_docu_no = ifs_docu_no
temprec!lbr_pay_pd_no = lbr_pay_pd_no
temprec!prod_ind = prod_ind
temprec!reject_cd = reject_cd
temprec!correction_cd = correction_cd
temprec!load_date = load_date
temprec.Update
temprec.Close
Could someone please help?
|
|
|
|
|
You could allways just make a collection and override the toString method or make a new method, to output each element. And override the Add method. For example:
class Queries : ArrayList {
...
public override int Add(object obj)
{
return base.Add(obj.ToString());
}
public override stringToString()
{
string output = "";
foreach (string query in this)
{
output += "," + query;
}
return output;
}
}
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
You could use a stored procedure instead of dynamic SQL.
Then you could put the IF inside that.
Any reason you're wanting to use a blank string instead of a NULL for the default date?
Cheers,
Simon
"Sign up for a chance to be among the first to experience the wrath of the gods.", Microsoft's home page (24/06/2002)
|
|
|
|
|
I didn't try NULL, I didn't even think about using that in C# because it didn't work in my VB code. Thanks, I will try it.
|
|
|
|
|
Hi,
Through "My Network Place" in Windows Exploer, we can see the entire network hierarchy. I am looking for a way to recreate this hierarchy in C# and display it in treeview. I have been seeing lots of examples for Directory, DirectoryInfo class to get local information. But how about network? I appreciate your help!!
|
|
|
|
|
Actually it is a directory. I don't know what the equivelant in c# is or if there is an equivelant, but in mfc you use the SHGetFolderLocation with CSIDL_NETHOOD to access the NetHood directory.
|
|
|
|
|
Hi,
I think my problem is easy to solve, but I'm giving too much time while I can solve it in other ways (uglier ones...).
That's it:
I've got a form which instantiates a simple form to get a user & pwd. When the Show method is finished I would like to get the values of the strings (properties) in the calling form. I can do it creating two public strings at the called form which are initialized to the Edit Controls value and read by the calling form when the Show method finishes.
It's a simple solution, but I want a better one:
Is it possible to pass the reference of the local strings to the constructor of the called form so when the Show method finishes the calling form already has the initialized values?
I also tried to use Marshal interface and IntPtr, but the solution became uglier by moments...
Does anyone know how to manage it?, is it possible?, maybe is there any similar solution which save me to create to public strings in the called form?
Thank you in advance,
Edgar
__________________________________________
Edgar Berengena Moreno
Software Engineer
Appeyron Research
|
|
|
|
|
Default param passing is by ref, so nothing prevents you from the caller Form to do this :
Form2 f = new Form2();
f.SetFormData(m_arrayData);
f.Show();
where m_arrayData is whatever collection, such as System.Collections.ArrayList for instance.
Be warned though that .Show() returns immediately after the Form is displayed, thus you never know when the collection is updated, etc. Unless instead of passing a collection, you pass a class with a collection member and a SetDirty() method to tell the caller.
Another interesting point is that the Form2 subform should not call you, but instead raise an event the caller Form has subscribed for. That's much more standard C#/Java programming-style.
See http://www.codeproject.com/csharp/delegates-part1.asp[^]
And I swallow a small raisin.
|
|
|
|
|
I used the wrapper to make my C# program to recognize the datatype win32_find_Data, however, the compiler doesn't accept the IntPtr as the return type for function "Findfirstfile", what's the solution for this? Following is the sample code:
struct FILETIME
{
int dwLowDateTime;
int dwHighDateTime;
}
struct WIN32_FIND_DATA
{
int dwFileAttributes;
FILETIME ftCreationTime;
FILETIME ftLastAccessTime;
FILETIME ftLastWriteTime;
int nFileSizeHigh;
int nFileSizeLow;
int dwReserved0;
int dwReserved1;
string cFileName; //mite need marshalling, TCHAR size = MAX_PATH???
string cAlternateFileName; //mite need marshalling, TCHAR size = 14
}
[DllImport("kernel32.dll")]
static extern IntPtr FindFirstFile( IntPtr lpfilename, ref WIN32_FIND_DATA
findfiledata);
|
|
|
|
|
Declaration :
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct FILETIME
{
public Int32 dwLowDateTime;
public Int32 dwHighDateTime;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct WIN32_FIND_DATA
{
public Int32 dwFileAttributes;
public FILETIME ftCreationTime;
public FILETIME ftLastAccessTime;
public FILETIME ftLastWriteTime;
public Int32 nFileSizeHigh;
public Int32 nFileSizeLow;
public Int32 dwReserved0;
public Int32 dwReserved1;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst= 260)]public string cFileName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst= 14)]public string cAlternateFileName;
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
public static extern IntPtr FindFirstFile( string lpfilename,
out WIN32_FIND_DATA findfiledata);
Usage :
String s = @"*.js";
WIN32Wrapper.WIN32_FIND_DATA findfiledata;
IntPtr handle = WIN32Wrapper.FindFirstFile( s, out findfiledata);
And I swallow a small raisin.
|
|
|
|
|
well, still encounter the same problem.
|
|
|
|
|
Works fine for me,
If you have a problem compiling this code, then the bug is trivial, it is not even a marshalling problem,
And I swallow a small raisin.
|
|
|
|
|
|
I need opinions on how to build the following component...
The file server holds 5 XML files. These 5 XML files (yes, only five) contain all of the data for a rather large enterprise-level application. I need to create a single object to be used in both a web application and a Windows application. Both of these applications will need to insert, update, select, and delete XML nodes and attributes from these same files at the same time.
Obviously, my concerns are file locking and massive memory consumption using multiple instances of this object. Also, the data in each of these files cannot be out of sync at any moment.
Unfortunately, I cannot deviate from these requirements. I'd like some advice on creating the object and using these five files. Any and all ideas are welcome.
Thanx,
Ryan
|
|
|
|
|
I guess the IDataSet object would be fine, as it stores data in native Xml, allows to work offline, loads/saves xml, ...
God luck,
And I swallow a small raisin.
|
|
|
|
|
Yeah, but how will it handle multiple requests coming in for the same instance of the document?
|
|
|
|
|
There is no free lunch whatsoever, you'll have to code something someday...
But IDataSet manage states such like what you may imagine behind methods like HasChanges(), GetChanges(), RejectChanges(), ...
You should give it a try.
And I swallow a small raisin.
|
|
|
|
|
I would like to write a C# program that will allow me create and/or load the image file of a floppy over our company intranet.
I was reading that the WMI in VC++ is the same as the System.Management Namespace in C#. I was wondering if I could use this to achive my goal. Please, let me know if I'm even on the right track. I don't even know what a Management Object is!
Thanks,
TeraCoder
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
Can any one help in finding tutorial/sample for Serial Port Communication (COM)in C#.
thanks,
Sanjeev
|
|
|
|
|