|
i thougt i'd already answered... hm, maybe i forgot to post it
i've created the project with the option "component registrar". do i have to call the RegisterAll function of the Registrar class?
in vc 6 i never had to register the class factory separately... so i don't really know what to look for :-> . can you please check it in my sourcecode i've posted before?
i know that i can youse P/invoke. but i've choosen to build a com wrapper, because i want to have a more general solution. so i can use it with other languages... and i found the event handlers better than hooking on notify messages (in C#) the CapiThread.dll sends.
thx.
Martin
|
|
|
|
|
Hi Everybody !
in btnShow_Click() :
try<br />
{<br />
string query="Select * from TestReport";<br />
con.Open();<br />
da=new SqlDataAdapter(query,con);<br />
sqlcmb=new SqlCommandBuilder(da);<br />
da.Fill(DS,"TestReport");<br />
dt = DS.Tables["TestReport"];<br />
dv = dt.DefaultView;<br />
dataGrid1.DataSource=dv;<br />
con.Close();<br />
sqlcmb.Dispose();<br />
con.Dispose();<br />
}<br />
catch(Exception ex)<br />
{ <br />
MessageBox.Show(ex.ToString());<br />
}<br />
}
at the first I have no problem for showing records , but at the second when I press th Show Button , I have this error :
The ConnectionString property has not been initialized !
thanx for any help !
Regards ,
s_mostafa_h
|
|
|
|
|
Hello
Your problem is in this line:
con.Dispose();
You shouldn't dispose the connection if you'll use it again. also I don't recommend opening/closing the connection each time you make a query.
Regards
|
|
|
|
|
hi there ,
but , if it does'nt Dispose() , eachtime , I press the button , all previous records is added again to the end of record .
thanx a lot ,
s_mostafa_h
|
|
|
|
|
Try clearing your data objects explicitly rather than disposing the connection.
|
|
|
|
|
connection(con) has not any property for "Clear()" , Ccan u more explain , plz?;)
s_mostafa_h
|
|
|
|
|
Hello
You shouldn't dispose your connection until you don't need it anymore in the current session. If you want to clear you DataGridView -as I understood from your reply-, then you should call the DataGridView.Rows.Clear() method before filling it again.
Regards
|
|
|
|
|
Nader Elshehabi wrote: You shouldn't dispose your connection until you don't need it anymore in the current session. If you want to clear you DataGridView -as I understood from your reply-, then you should call the DataGridView.Rows.Clear() method before filling it again.
This is what I was getting at - sorry for the lack of detail.
|
|
|
|
|
Hi,
try setting the
con.ConnectionString property
before opening the connection ie, use
con.ConnectionString="your connectionstring";
con.Open();
hope this works.
Nitin...
|
|
|
|
|
I want to be able to select a region of a picture (hover over it with a mouse and select it) and cut out a piece that i selected. I am using the mouseMove event to figure out the position of my pointer, but I am not able to capture the coordinates. I only see the coordinates from when the mouse enters the image and when it leaves. What am I doing wrong?
|
|
|
|
|
I think that a snippet of your code would help here...
Maybe you can post your MouseMove event handler code...?
|
|
|
|
|
Hello
I guess you handled the MouseMove event of your form. Instead you should handle the MouseMove event of your PictureBox or whatever control you're showing the picture in.
If not so, do you lose mouse coordinates when entering the picture, or when leaving it?? ie. Do you track the mouse currently inside or outside the picture??
Regards
|
|
|
|
|
Working on a project that involves generating SVG (Scalable Vector Graphics) charts with C# I have come across the following problem. For reasons of performance I would like to use CSS (Cascading Style Sheets) to represent style properties of SVG elements.
Finally it should look something like that:
<style>
.rectangle
{
fill: blue;
stroke: green;
stroke-opacity: 0.5;
}
</style>
<svg>
<rect x="100" y="40" width="200" height="29" class="rectangle" />
</svg>
A style-area defines all CSS rules which will then be applied in various elements in the SVG document. I'm striving for an elegant solution to represent the CSS properties adequately. Shall I build a few classes representing CSS stylesheets and include these in my classes generating SVG output via composition (see following code snippet).
As you can see the SVG (XML) output is generated via XmlTextWriter class.
<code>
public class SvgElement
{
double x1, x2, y1, y2;
XmlTextWriter writer;
CSSRule rule; // include css rules via composition?
public SvgElement(double x1, double x2, double y1, double y2)
{
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
}
public void Draw()
{
writer.WriteStartElement("line");
writer.WriteAttributeString("class", rule.name);
writer.WriteAttributeString("x1", coordX1.ToString());
writer.WriteAttributeString("y1", coordY1.ToString());
writer.WriteAttributeString("x2", coordX2.ToString());
writer.WriteAttributeString("y2", coordY2.ToString());
writer.WriteEndElement();
}
}
</code>
As I'm lacking to describe my problem precisely, please do not hesitate to comment. I'm more than willing to give further details
Thanks,
Goebel
-- modified at 3:07 Tuesday 22nd August, 2006
|
|
|
|
|
Hi guys.
In my project, I'm opening an MS Excel file and then trying to update some of the cells within it. The only catch however is this particular excel file contains two additional pivottables as well which contain a macro that executes code the instant the excel file is opened.
So, due to the fact that I'm trying update cells at the same time this macro is trying to execute its code, I'm receiving an error which reads:
"Call was rejected by callee"
I've provided my code below. It fails on line 3 ("sheet = MSExcel..."):
----------------------------------------------------
workbook = excel.Workbooks.Open(filePath,0, false, 5, "", "", false, MSExcel.XlPlatform.xlWindows, "",true, false, 0, true, false, false);
sheet = (MSExcel.Sheets)workbook.Worksheets;
worksheet = (MSExcel._Worksheet)sheet.get_Item(currentSheet);
------------------------------------------------------
Apparently, Excel is single-threaded so it can't handle two things at once. I noticed this because while debugging, if I set a breakpoint on my line of code that opens excel and "step into" the next few lines of code, everything works fine (i.e. I gave the macro enough time to execute its code first).
So anyway, I was just wondering if anyone has ever come across this issue before and what can be done to correct it.
Thanks in advance.
-Goalie35
|
|
|
|
|
Here is a hack workaround. So, go ahead and skip this reply if you want a clean solution.
In my experience I've found that Excell/Access/Word Macros are basically hack jobs anyway, so it probably won't hurt much hacking it up some more.
Can you modify the macro that runs when the file is opened every time that you run that code?
Alternatively modify the macro to check for a condition that you set to exit immdediately.
Example:
Step 1.) Modify or remove problem macro
Step 2.) Run your code
Step 3.) Restore problem macro
Step 4.) Possibly run problem macro
|
|
|
|
|
I have a user control that I would like to embed win forms controls in (for example System.Windows.Forms.Button)
I would like to embed the control in a control that is a property on my user control
I do not know how to then make the embedded control paint so that the user can see it.
public class SideBarMenu : UserControl
{
public class MyMenuItem : Control
{
public bool isActive = false;
}
// ... other code omitted
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
//what do I do to paint the child controls
//that can be contained in a MyMenuItem
}
}
public class Test1
{
public static void Test()
{
SideBarMenu mnu = new SideBarMenu();
MyMenuItem i = mnu.AddMenuItem("Hello");
Button b = new Button();
b.Text = "button1";
i.Controls.Add(b);
}
}
|
|
|
|
|
Hello
Maybe I'm not following you! So forgive me if I stray.
You don't have to worry about painting any controls inside your custom control. Just define their sizes and locations and they will draw themselves. You have only to paint your control to be viewd properly to the user, and of course to have a valid size to view all sub-controls.
So in the paint method you only have to paint your control, maybe would want to refresh() or invalidate() all sub-controls and they will draw themselves.
Another event you might want to handle is AddedControl. Have a look at it on MSDN.
Regards
|
|
|
|
|
I have a method:
internal void SetTopic( )
{
}
Using Reflection I want to call it
PropertyInfo method = type.GetMethod("SetTopic", BindingFlags.?);
Which binding flag do I include to find a method with an Internal modifier?
Thanks,
Nick
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
MethodInfo method = type.GetMethod("SetTopic", BindingFlags.Instance | BindingFlags.NonPublic);
Vitaliy Tsvayer
Tikle
|
|
|
|
|
I want to add a new line to one of the Datagrid Column Value.
How do i do it
Suppose i have Mike and Bond
and i want Mike and Bond in different lines but in the
same column.
Thanks
Kal
|
|
|
|
|
Hello
Correct me if I'm wrong, but I don't think it's possible.
Regards
|
|
|
|
|
You can set DefaultCellStyle.WrapMode = DataGridViewTriState.True.
So, you can enter value to cell as "Mike" + Environment.NewLine + "Bond".
BUT, in this case if some other cell width is small its value will be wrapped as well.
To avoid this you can leave DefaultCellStyle in its default value and set individual cell's style only.
Vitaliy Tsvayer
Tikle
|
|
|
|
|
Hello,
I have a project in Visual Studio that references some external "Debug" dll's. It works fine in "Debug" mode.
I want to rebuild this project in "Release" mode. Visual Studio complains that it cannot find the "Release" version of those external dlls. When I try to add the "Release" version of that external dll it complains that a reference to this dll (Debug version) already exists in this project. Replacing the the "Debug" version of the external dll with its "Release" version lets me rebuild my project in "Release" mode.
I was wondering if there was a way around this, instead of switching the versions of the external dll's I use (between "Debug" and "Release") everytime I want to do a "Debug" or "Release" version of my project.
I've never seen this before, it usually just finds the right dll by default. It suprised me.
Thanks and Regards,
Ramanan
"One of the Georges," said Psmith, "I forget which, once said that a
certain number of hours' sleep a day--I cannot recall for the moment how
many--made a man something, which for the time being has slipped my
memory."
|
|
|
|
|
Hello
AFAIK your project shouldn't care if the version of the external dlls is debug or release. Did you make these dlls?? Maybe you referenced them by the project?? Try cleaning things up:
1- BACKUP YOUR PROJECT -sorry for the uppercase;)-
2- Remove all references to the dlls
3- Copy only the dlls files to your project's folder
4- Reference to the new dlls in your folder
5- Make sure "Copy Local" property is set to true
Regards
|
|
|
|
|
I am looking for a good tutorial for C# for the web, for someone that has never touched an ounce of C code in his life (ASP, VB, HTML, some Java). If anyone knows any that are useful, and have been in the same situation I am, please post them here. I have a book and have been going through it, but I'm still not grasping the fundamental and required things a C# wep-page should be built around; any tutorials that compare C# to ASP or HTML and teach it comparitively would be wonderful. Thanks in advance!
Jesse "Soot" Myer
jessemyer06@aol.com
|
|
|
|