|
On occasion,when I am programing in VS 10, I will have an issue with a control, usually a button. Apparently I do something (I do not know what) and the application "loses" the original code behind a control and renames a new identical control with the name 1 after it.
Case in point:
private void buttonUsers_Click_1(object sender, EventArgs e)
{
}
The original control is still there someplace and the code is intact, but the control no longer points to it. It points to the new blank definition instead. In the past, if it was a single issue (1 control) deal, I simply recoded the new button with the code from the old one and moved on, but this time, all the buttons on the page are gone. In fact, all the buttons in the application seem to be the same way. I think it is time to find out why. I hope that someone can tell me what I am inadvertently doing to cause this and how I can recover the application to where it was. I am at a loss...I appreciate your help...Thank You ... P
|
|
|
|
|
I haven't experienced that kind of thing, and since you don't know how to reproduce this, I cannot help you on that front right now. Could you provide your solution files to see if we can reproduce your situation? also, try and do whatever you are doing regularly when this happens and take notice of all of it, try and give us the steps to reproduce your problem so we can help you figure out what is happening
Now, regarding this:
PDTUM wrote: how I can recover the application to where it was
I can't think of anything to help you recover it to where it was, but you should always have some form of backup of your code.
For future ocassions I would recommend using Source Code Control, even when working alone on a project, since you will have backups (preferably set the server on another machine) and you will be able to revert back to older versions of the code.
If you have access to TFS (Team Foundation Server) that would be great since Team Explorer integrates pretty well with VS, if you don't try Subversion or TortoiseSVN, failing all that, zip up your code and put your zips (or RARs or whichever compressed format you prefer) in a safe place (i.e. cloud storage - SkyDrive, Google Drive, DropBox), my point here is, no matter how rudimentary (or sophisticated) but always have a backup of your work.
|
|
|
|
|
Emmanuel,
Thank you for your input. This happens semi often, but it never affected more than one control before. I wish I could reproduce it, but I cannot. I was hoping that you might have seen this and just knew what the heck it was that I did, not just for this time but for the next time. Anyway...I do have a backup of the app, but it will take me the better part of a day to get back to where I was...it happens that way sometimes. I appreciate the time and effort for your detailed response (and advice). Best Regards, Pat
|
|
|
|
|
Check The Designer Class of your form and delete "buttonUsers", manually.
|
|
|
|
|
Hello Smart...Thank you for your reply. I did not understand this, but I tried it anyway. It generated 11 errors and the application would no longer load generating the following response:
"The variable "buttonUsers" was either never declared or was never assigned."
I appreciate your effort. If you have another idea or if I did this wrong, please let me know. I suppose that I will have to go back and rebuild at least 12 hours of previous code to get back to where I was....Oh well.
Best regards, Pat
|
|
|
|
|
Hello, Hope this will help:
1-Find all "buttonUsers" in entire Solution.
2-Delete all of them.
The Declaration
The Delegate
The Events
3-Open The From Designer and from Properties window Search for ButtonUsers, ( Manually ) if you find it Change it's Name to Something like "ButtonUsersXXX"and repeat Step 1 and step 2.
4- Build your Solution if you got an Error ( I hope you don't) Double click it, and post the line of the code which produce it here .
Have a good day Sir.
|
|
|
|
|
In a C# 2010 application, I am using linq to sql to connnect to a sql server 2008 database. From the linq statement listed below,
I am trying to obtain the OrgName as a string value. However I keep getting errors trying to make this occur.
string strCustnUM = CUSTOMERNUMBER;
var varOrgName = (from o in rData.Orgs
join pl in rData.Custs on o.OrgID equals pl.OrgID
where pl.orgnum == strContract
select(o.OrgName).SingleOrDefault());
string strOrgName = Convert.ToString(varOrgName);
Thus can you tell me how to change the linq statement so that I obtain the OrgName as a string value that I can use in the C# application?
|
|
|
|
|
Hmm, the structure of the query looks interesting. Try this:
var varOrgName = (from o in rData.Orgs
join pl in rData.Custs on o.OrgID equals pl.OrgID
where pl.orgnum == strContract
select o.OrgName)
.SingleOrDefault();
djj55: Nice but may have a permission problem
Pete O'Hanlon: He has my permission to run it.
|
|
|
|
|
Matt (above) is right, if that doesn't solve your problem, could you copy-paste the error you get, and tell us the data type of o.OrgName?
|
|
|
|
|
Can anyone explain me, What is EncoderValue.CompressionLZW in C#
|
|
|
|
|
It specifies that you want to save an image using LZW compression.
/ravi
|
|
|
|
|
These enumerations are specified when JPEG or TIFF encoders are being used with the Image.Save method.
This particular value specifies the LZW compression scheme. Can be passed to the TIFF encoder as a parameter that belongs to the Compression category.
|
|
|
|
|
I have a generic queue. in that queue multiple threads will enqueue and one thread will dequeue from it. Now i am using lock(object) for enqueue and dequeue oprations. But i need a lock free mechanism for this as we have a Queue.Synchronized() method for Queue. Is there any better mechanism for this, because i am dealing with millions of records.
advance Thanks for replies
|
|
|
|
|
There's no such thing as a "lock free" method of doing this.
Internally, the Synchronized collections all use some kind of locking mechanism to keep them thread-safe. I believe ConcurrentQueue uses the SpinWait class, which is a nothing more than a Thread.Yield and Sleep wrapped in a counter.
|
|
|
|
|
I am using LINQ in my project. I have tried using update query. But this is not working for me.
Please any body help me. Did I need to change any settings of my database? or for the datacontext?
My code is as follows:
here dc is the datacontext, getinteger() is an extension method, ucItem is a custom control,
Common is a class
if (clsTblAsset.AssetId == 0)
{
clsTblAsset.StockId = ucItem._Id.getInteger();
clsTblAsset.RefId = 0;
clsTblAsset.RefModule = "S";
clsTblAsset.AssetEntryDate = DateTime.Now.Date.getDateTime();
clsTblAsset.LoginId = ClsParameters.LogInId;
Common.dc.TblAssets.InsertOnSubmit(clsTblAsset);
}
Common.dc.SubmitChanges();
Can any body help me now please..
Regards,
Jineesh
|
|
|
|
|
jini4 wrote: But this is not working for me.
Sorry, my crystal ball is at the cleaners, could you - just this once - tell me what the problem is.
|
|
|
|
|
Hi J4amieC
My code is as follows:
here dc is the datacontext, getinteger() is an extension method, ucItem is a custom control,
Common is a class
if (clsTblAsset.AssetId == 0)
{
clsTblAsset.StockId = ucItem._Id.getInteger();
clsTblAsset.RefId = 0;
clsTblAsset.RefModule = "S";
clsTblAsset.AssetEntryDate = DateTime.Now.Date.getDateTime();
clsTblAsset.LoginId = ClsParameters.LogInId;
Common.dc.TblAssets.InsertOnSubmit(clsTblAsset);
}
Common.dc.SubmitChanges();
Can you help now please..
Regards,
Jineesh TR.
-- modified 28-Sep-12 6:31am.
|
|
|
|
|
The one important detail you left out is what do you mean by "it's not working"! That's the definition of what the problem is, not what all these little things in the code are.
What is it actually doing? What's the expected behavior? Are there any error messages?? Did you step through the code line by line and inspect the variables to make sure everything is as it should be?
|
|
|
|
|
Thank you Dave Kreskowiak,
This is the code for saving the 'asset' details. The asset details are saving in to the table TblAsset.
public static LINQtoSQLAssetMeterDataContext dc=new LINQtoSQLAssetMeterDataContext("ConnectionString");
protected override void Save()
{
if (clsTblAsset == null) clsTblAsset = new TblAsset();
clsTblAsset.AssetConditionId = cmbAssetCondition.SelectedValue.getInteger();
clsTblAsset.SerialNo = txtSerialNo.Text.getString();
clsTblAsset.ServiceTag = txtServiceTag.Text.getString();
clsTblAsset.CostCenterId = cmbCostCenter.SelectedValue.getInteger();
clsTblAsset.AssetStatusId = cmbAssetStatus.SelectedValue.getInteger();
clsTblAsset.Description = txtDescription.Text.getString();
clsTblAsset.LocationId = cmbLocation.SelectedValue.getInteger();
clsTblAsset.AssetNo = txtAssetNo.Text.getString();
if (pictBarcode.Image != null)
clsTblAsset.BarCode = barcodePict;
if (pictAsset.Image != null)
clsTblAsset.AssetPict = assetPict;
clsTblAsset.Notes = txtNotes.Text.getString();
if (clsTblAsset.AssetId == 0)
{
clsTblAsset.StockId = ucItem._Id.getInteger();
clsTblAsset.RefId = 0;
clsTblAsset.RefModule = "S";
clsTblAsset.AssetEntryDate = DateTime.Now.Date.getDateTime();
clsTblAsset.LoginId = ClsParameters.LogInId;
dc.TblAssets.InsertOnSubmit(clsTblAsset);
}
dc.SubmitChanges();
}
If the AssetId is zero, then details are inserted to the table. and if the AssetId>0, asset details are updated to the table.
Here the problem I am facing is that,
Once if we insert in to the table, all the details are inserted properly. Once if we are editing an 'asset' data and changing the value and updating the table, The data is not get updated. But no errors or exception is occuring.
Please let me know, if any one knows it.
Regards,
Jini4
|
|
|
|
|
Put a breakpoint on the first line in this Save method. Once execution hits the breakpoint, it'll stop and you can step through the code line-by-line and inspect variables up to the point. I'm pretty sure you'll find a value that's not what i't supposed to be.
|
|
|
|
|
|
Would you care to elaborate as to what the problem actually is? the exact error message (if any), which line, or how is it behaving and how do you expect it to behave.
Also, you said you were trying to update, but I see an InsertOnSubmit in your code...
|
|
|
|
|
Thank you Emmanuel Medina Lopez,
This is the code for saving the 'asset' details. The asset details are saving in to the table TblAsset.
public static LINQtoSQLAssetMeterDataContext dc=new LINQtoSQLAssetMeterDataContext("ConnectionString");
protected override void Save()
{
if (clsTblAsset == null) clsTblAsset = new TblAsset();
clsTblAsset.AssetConditionId = cmbAssetCondition.SelectedValue.getInteger();
clsTblAsset.SerialNo = txtSerialNo.Text.getString();
clsTblAsset.ServiceTag = txtServiceTag.Text.getString();
clsTblAsset.CostCenterId = cmbCostCenter.SelectedValue.getInteger();
clsTblAsset.AssetStatusId = cmbAssetStatus.SelectedValue.getInteger();
clsTblAsset.Description = txtDescription.Text.getString();
clsTblAsset.LocationId = cmbLocation.SelectedValue.getInteger();
clsTblAsset.AssetNo = txtAssetNo.Text.getString();
if (pictBarcode.Image != null)
clsTblAsset.BarCode = barcodePict;
if (pictAsset.Image != null)
clsTblAsset.AssetPict = assetPict;
clsTblAsset.Notes = txtNotes.Text.getString();
if (clsTblAsset.AssetId == 0)
{
clsTblAsset.StockId = ucItem._Id.getInteger();
clsTblAsset.RefId = 0;
clsTblAsset.RefModule = "S";
clsTblAsset.AssetEntryDate = DateTime.Now.Date.getDateTime();
clsTblAsset.LoginId = ClsParameters.LogInId;
dc.TblAssets.InsertOnSubmit(clsTblAsset);
}
dc.SubmitChanges();
}
If the AssetId is zero, then details are inserted to the table. and if the AssetId>0, asset details are updated to the table.
Here the problem I am facing is that,
Once if we insert in to the table, all the details are inserted properly. Once if we are editing an 'asset' data and changing the value and updating the table, The data is not get updated. But no errors or exception is occuring.
Please let me know, if any one knows it.
Regards,
Jini4
|
|
|
|
|
how to upload a song and retrieve the song from database..
please give any idea about on this....
|
|
|
|
|
1-Create database with table : tbSongs
guid | songname | songfile
----------------------------
guid uniuqeidentfieir
songname varchar(255)
songfile image
2-Convert your song to byte array
public static byte [] File2ByteArray (string szFileName)
{
Stream st = new FileStream (szFileName,FileMode.Open);
byte[] bit = new byte[st.Length];
st.Read(bit, 0 , (int)st.Length);
st.Close();
return bit;
}
3-Store it in tbSongs
#region Fields
private Guid _guid;
public Guid guid
{
get
{
return _guid;
}
set
{
_guid = value;
}
}
private string _songname;
public string songname
{
get
{
return _songname;
}
set
{
_songname = value;
}
}
private Byte[] _song;
public Byte[] song
{
get
{
return _song;
}
set
{
_song = value;
}
}
#endregion
#region Database
public void Insert()
{
DBConnect.DBCommand.CommandText = "INSERT INTO tbSongs VALUES (?, ?, ?)";
DBConnect.DBCommand.Parameters.AddWithValue("@guid", guid);
DBConnect.DBCommand.Parameters.AddWithValue("@songname", songname);
DBConnect.DBCommand.Parameters.AddWithValue("@image", song);
DBConnect.DBCommand.ExecuteNonQuery();
DBConnect.DBCommand.Parameters.Clear();
}
to retrive the song from database :
Find you song with guid or name and cast datareader to bytes array.
public static byte[] GetFilebytes(guid guid)
{
DBCommand = new DBCommand("SELECT songfile FROM tbsongs WHERE guid = @guid", DataBase.DBConnection);
DBCommand.Parameters.AddWithValue("@guid", guid);
byte[] filebytes = (byte[])DBCommand.ExecuteScalar();
DataBase.DBCommand.Parameters.Clear();
return filebytes;
}
4-Use File Stream or Memory Stream to Save your Song
byte[] filebites = GetFilebytes(songguid)
FileStream fs = new FileStream("c:\\mysong.mp3", FileMode.CreateNew, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
bw.Write(filebytes);
bw.Close();
fs.Close();
Hope this help
|
|
|
|