|
The secret is in reading the excepion text :P
toink toink wrote: The process cannot access the file because it is being used by another process.
Which means someone already has a lock on that file. Possibly you.
There are a few tools around which allow you to investigate the locks on a file. Theres a few at SysInternals[^] but personally I like Unlocker[^].
|
|
|
|
|
hi there,
i have a problem that is when i write connection string of sql like this
dataConnection.ConnectionString = "Data Source= MATO\\SQLEXPRESS; Integrated Security=true; Initial Catalog=ABCdatabase;";
then its works
but when i wrote something like this
string connection = File.ReadAllText(@"C:\Documents and Settings\Quarantined\Desktop\connection.txt");
dataConnection.ConnectionString = connection;
its giving error "Instance Failed"
the connection.txt file contains the same line which is written above for connectionstring
any one know the solution ../?
Becoming Programmer...
|
|
|
|
|
I guess. maybe. there are some whitespace or newline in that textfile..
Why do you wanna store the connection string in textfile? I would suggest you to store the connectionstring in either App.Config or web.config.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
I feel really stupid right about now.
I have had someone explain it to me but I don't understand. I have a checkedlistbox which i want to allow multple skills to be matched against a person. I have dataadapters and sql server database. I have an employees with employeeID table and a technicalskills table with techskilsID . I was told to create another table with tchskillsid and empid so I can save multiple selections in there. My code is all over the place. I'm sure no one will want to help me with this one which is understandable, but I don't know where to turn to. Apparently I have to get the ID's from the selected text by using select statement and then insert into the new employeeskillset table and match against empid in the employees table and store the record in there against the persons name. confused yet? I am.
The following returns error:
Error 5 No overload for 'empSaveButton2_Click' matches delegate 'System.EventHandler'
My CODE
private void empSaveButton2_Click(object sender, DataSet dataset, string connectionString, string queryString, EventArgs e)
{
myConnection = new SqlConnection("server = ADMMSAS7;database=Dev_RST;Trusted_Connection=yes");
myConnection.Open();
// foreach (int indexChecked in techSkillsCheckListBox2.CheckedIndices)
// {
for (int x = 0; x <= techSkillsCheckListBox2.CheckedItems.Count - 1; x++)
// {
// If so, loop through all checked items and print results.
{
DataSet ds = new DataSet();
string sql = "Select t.TechnicalSkillsID from TechnicalSkills t where t.TechnicalSkillsID = '" + techSkillsCheckListBox2.CheckedItems[x] + "')";
SqlDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = new SqlCommand(sql, myConnection);
adapter.Fill(ds, "TechSkillSet");
DataTable dt = ds.Tables["TechSkillSet"];
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn col in dt.Columns)
sql = "Insert into TechSkillSet (EmployeeID,TechnicalSkillsID) values (" + techSkillsCheckListBox2.CheckedItems[x] + " , " + FirstnameText.Text.ToString() + " , " + Lastnametext.Text.ToString() + ")";
}
{
|
|
|
|
|
Hi , im developing an application its all working fine untill recentrly i got an error:
"error creating window handle" ,
so i was googling on the subject and i found out it happens when youre application is using 2 many controls
and thats indeed my case , so the solution was to replace the controls by drawing directly to the graphics of the parent control instead of making new child controls , for example if i have a panel , and i got like 1000 labels inside that panel , the idea is to do something like:
Graphics g = Graphics.FromHwnd(mypanel.Handle);
g.drawString(string,font....);
instead of adding 1000 labels to the panel.
ok so here is the problem i am trying to adopt this technique but i found out that in cases when i minimize
the window and then resize it back i see that all my drawings are gone , or when the panel uses the autscroll
when it appends the scroll bars same thing happens
all the drawings are gone ,
so my question is, is there any way to make these drawings stay permenently on the control , or i will have to make many eventhandlers and repaint evrything evrytime something happens....
or is there any other solution for this kind of problem thanks.
Net
|
|
|
|
|
this problem comes when u r not disposing objects properly.so
dispose the objects properly and try to repaint again.
rahul
|
|
|
|
|
sorry for the late reply and thanks for replying my question.
I didnt understand what you mean by "u r not disposing objects properly",
Did you reffer to the part where: when i draw on the control all my drawings are gone?
if so, how can i dispose the object properly so it wont happen , could you be a bit more specific? ,
thanks alot.
Net
|
|
|
|
|
This was a question on a students exam:
Shown was a static void main, and a second class, titled Punta.
namespace Test
{
class Test
{
static void Main(string[] args)
{
Punta punt = new Punta();
double bla = punt.Search();
}
}
class Punta
{
double Search()
{
return 5.0; //assume we calculated something here and found it
}
}
}
Question was: Is this code executable? (Exam) Answer: No
Q for codeproject: CAN you compile, link and execute wrong code like this? Or is the only way to do so by supressing warnings and errors from the compiler?
Question 2 was: If it's not executable (which was assumed you've noticed), the question was: Why?
And, how can you fix that, without changing the code of Punta-class.
The expected answer for the teacher was: An interface.
Followed by lines of code to make it accessible.
BUT... it did say, "you may NOT change the code of the class 'Punta'". But how is that some people say: If you use an interface, you're actually modifying the class. And some say, you aren't.
Which is it?
-- modified at 23:04 Wednesday 5th September, 2007
|
|
|
|
|
Unless something was lost in translation, and certainly some code was, the problem is that
'Punta.Search()' is inaccessible due to its protection level
which can't be fixed without changing class Punta. An interface won't fix the situation as posted.
|
|
|
|
|
Agree, either you add a public or if you use an interface and use it explicit you have to add the interface name plus a . to "Search"
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
... and you'd still have to add public to the method.
|
|
|
|
|
not when you explicitly implement it, then no modifier is allowed.
-^-^-^-^-^-
no risk no funk ................... please vote ------>
|
|
|
|
|
"double void" ? I want one of those!
|
|
|
|
|
mizitras wrote: Question was: Is this code executable? (Exam) Answer: No
Correct, it won't even compile.
mizitras wrote: Q for codeproject: CAN you compile, link and execute wrong code like this? Or is the only way to do so by supressing warnings and errors from the compiler?
Question 2 was: If it's not executable (which was assumed you've noticed), the question was: Why?
You can suppress warnings, not the errors. No, you still won't be able to compile this thing since the "double void Search()" will confuse the compiler. It won't make any assumptions about what you really mean here. You cannot have two return types.
mizitras wrote: And, how can you fix that, without changing the code of Punta-class.
You can't. The Punta class MUST be changed to specify a single return type for the Search method. Also, since the default protection level is private, you must specify the Search method as public or internal for it to be seen outside the Punta class.
An interface will NOT fix this problem since interfaces do not modify a class. Interfaces specify the methods that an implementing class must define. The class must still be modified to tell it which interface it's implementing. Either way, the Punta class must be modified in order for it to be fixed.
-- modified at 12:04 Tuesday 4th September, 2007
|
|
|
|
|
Aah dang, I accidentally typed "double void" instead of just double and void in the Search(void)
Now I've posted the wrong question
|
|
|
|
|
I would like to create a window with round edges with C#. In window Form there is a variable Region variable to set for such purposes.
First I can create a GraphicsPath with CreateGraphicsPath funcation.
public static GraphicsPath CreateGraphicsPath(Rectangle rect, float radius)
{
GraphicsPath gp = new GraphicsPath();
gp.AddLine(rect.Left + radius, rect.Top, rect.Left + rect.Width - radius, rect.Top);
gp.AddArc(rect.Right - radius, rect.Top, radius, radius, 270, 90);
gp.AddLine(rect.Right, rect.Top + radius, rect.Right, rect.Bottom - radius);
gp.AddArc(rect.Right - radius, rect.Bottom - radius, radius, radius, 0, 90);
gp.AddLine(rect.Right - radius, rect.Bottom, rect.Left + radius, rect.Bottom);
gp.AddArc(rect.Left, rect.Bottom - radius, radius, radius, 90, 90);
gp.AddLine(rect.Left, rect.Bottom - radius, rect.Left, rect.Top + radius);
gp.AddArc(rect.Left, rect.Top, radius, radius, 180, 90);
gp.CloseFigure();
return gp;
}
After that set
GraphicsPath gp = CreateGraphicsPath(ClientRectangle, radius);
this.Region = new Region(gp);
gp.Dispose();
After some time I would like to increase the size of window, which I am unable to do so. I tried creating new path and set to this.Region, but did not work. The window is not round any more. Any clue?
Thanks in advance if someone put light on it. If someone like to have code how I am increasing the size I can send the code as well.
agha.khan@hotmail.com
Agha Khan
|
|
|
|
|
Hey
I am creating a draughts game just to get me back into C# and I need to deal with user clicks (the user may click on a piece and then another valid sqaure on the draughts board) now rather than reading the mouses coordinates and looping through each piece or square until i find the correct one to send a message to is there a way of using the framework to handle this (maybe a class to derive from) or is this the best way of doing it?
Thanks
Dan
|
|
|
|
|
Your best bet is probably the way you're doing it, unless you feel it's justfied to write a class to handle each square, then you can iterate over those classes, looking for a hit.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You could create a UserControl that contains an 8x8 array of Button s - this would do away with the need to perform any hit test calculation.
/ravi
|
|
|
|
|
I would use one Panel the size of the playing board; and in its Click handler, convert
the mouse coordinates to the square's coordinates using division by square size.
No need to iterate at all.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Cheers every one - thats what i thought - the division by square size is a good idea, and the way Chris said was what I expected.
Dan
|
|
|
|
|
Hi, im using the WebBrowser control in my application.
When im accessing webBrowser1.Document everything is fine, but everytime i want to access the document of a frame (webBrowser1.Document.Window.Frames[0].Document) i get "UnauthorizedAccessException was unhandled". I tried different sites, but always the same.
When im using firefox or IE7 im always able to see the html code of the desired frames, but not in my application ...
Any suggestions?
|
|
|
|
|
Hello everybody,
In my study i need to build a spam filter using Artificial Immune System technique by C# programming.
I need to build my own one and will integrated with email client such as Mozilla Thunderbird.So,anybody got any source or opinion regarding this thing
|
|
|
|
|
starline wrote: anybody got any source or opinion regarding this thing
Nope, but you can be the first I suggest start planning/designing algorithms to accomplish this, and people on these forums are here to help if you get stumped.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hmmmm...I will design it and share with you all,anyway thanks a lot
|
|
|
|
|