|
This is a brutal way to cancel a SQL command. Ever considered trying SqlCommand.Cancel?
--------
"I say no to drugs, but they don't listen."
- Marilyn Manson
|
|
|
|
|
to do the SqlCommand.Cancel you probably would put that on ThreadAbortException............
|
|
|
|
|
Here's my situation: I have a database created with SQL Express. I have a VS solution that has a Windows Forms project. In the project I've added a datasource by clicking "Data->Add new datasource" I selected database as where to get the data from, then I selected my database, then I selected the tables that I wanted included in the DataSet. The dataset gets created all well and good. I add a dataset from the toolbox onto my form and set it's datasource property to my solution dataset. Then I add a binding source and set it's datasource to the list instance of the dataset (the one dragged from the toolbox) and it's datamember to the correct table. Then I bind all the controls on my form to the bindingsource. Then all I should need to do (according to everything I've read) is type:
this.Validate ();
this.epsBindingSource.EndEdit ();
this.epsTableAdapter.Update (this.oxfordDataSet.eps);
But this doesn't work, no data is ever added to the database. The Update method return 0 as the number of rows updated. I'm trying to add new data to the database, but it never works. I thought maybe it was something in the project or something I may have done wrong. So I created a completely new project added the datasource exactly how it should be done, and simply dragged the table I'm trying to update from the "Data Sources" window (in "detail" mode) onto the form and let the designer do everything for me. I typed my information into the form pressed the save button (on the bindingnavigator toolbar the designer created), but there was still nothing added to the database.
Any help on what I may be doing wrong would be very very appreciated. I've been dealing with this for a week and can't wrap my brain around why nothing is getting added to the database. I'm new to working with datasets, but I don't think I'm doing anything wrong.
- Aaron
|
|
|
|
|
I have a requirement for following matter. I have a MS word document any one can amend to it, but any one can't copy and paste it to their computer. I want to create a software tool for that. Please give me some ideas for that.
Lilupa.
|
|
|
|
|
I want set CheckBox is Items of DataGird In WinForm
Checkbox Items In A DataGrid WinForms C#
|
|
|
|
|
You bind a datagrid to a data source to display contents on the grid. Usually a dataset gets bound to the grid. In this case, if one of the columns in the dataset is a boolean value, checkbox automatically appears for that boolean column in the datagrid.
Ciao
There has to be more to life than just this
-- modified at 23:15 Thursday 23rd February, 2006
|
|
|
|
|
Can U give Source Demo ??
thanks
|
|
|
|
|
try this. Note that dataGrid1 must be a DataGrid control that you dragged and dropped onto your form.
using System.Data;
...
private void MainForm_Load(object sender, System.EventArgs e)
{
DataSet ds = new DataSet();
ds.Tables.Add ("One");
ds.Tables[0].Columns.Add ("A");
ds.Tables[0].Columns.Add ("B");
ds.Tables[0].Columns[0].DataType = typeof (bool);
ds.Tables[0].Columns[1].DataType = typeof (string);
ds.Tables[0].Rows.Add (new object[] {true, "First"});
dataGrid1.DataSource = ds;
}
...
Hope this helps.
There has to be more to life than just this
|
|
|
|
|
Thanks But I use DataGridTableStyle fill Data (Dataset->DataGird)
Ex:
DataGridTextBoxColumn dgColumn;
DataGridTableStyle dgTablestyle=null;
public void dgAddColum()
{
try
{
dgTablestyle.GridColumnStyles.Clear();
RemoveControlBindings();
AddDataControlBindings();
this.dgAssinStyle("dg_id","dg_id",dgTablestyle);
this.dgAssinStyle("dg_name","dg_name",dgTablestyle);
this.dgAssinStyle("dg_text","dg_text",dgTablestyle);
this.dgAssinStyle("dg_info","dg_info",dgTablestyle);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//Gan HeaderText, MappingName vao
public void dgAssinStyle(string headerText, string mappingName, DataGridTableStyle tablestyle)
{
dgColumn = new DataGridTextBoxColumn();
dgColumn.HeaderText = headerText;
dgColumn.MappingName = mappingName;
tablestyle.GridColumnStyles.Add(dgColumn);
}
After Add Collum CheckBox to DataGird
if U have a Ex for Me veryGood
thanks
|
|
|
|
|
Hello,
Use DataGridBoolColumn for boolean columns by checking their DataType property
HTH. Cheers.
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
My application is almost to an end. I have never tired deploying using the setup wizard in VS. In my design, one of the path name i need to retrieve from the registry, which is the path of installation file.
I know that i can enter some registry value during setup, this path is the path of installtion. How can i retrieve this path from the installtion path screen during setup?
|
|
|
|
|
there is no easy way for this. But you can write a program to retrieve the data contained by msi. refer to windowsinstaller documentation in msdn, query the registry table in MSI, (you can query msi database using msi sql) you will be able to get the value. oh, you probably need to call the program from customaction of setup project
|
|
|
|
|
I'm using the ActiveDocument.Reload() method after changing a document. I'm getting prompted to save my changes. Is there anyway I can disable these prompts or handle them through automation ?
|
|
|
|
|
Hi,
I am not sure why there is an underscore in the line below because this table is in an .xsd file without the underscore.
Thanks
foreach (TRCLNT01.TRCLNT01Row row in DataSetNew._TRCLNT01.Rows)
{
}
|
|
|
|
|
I have a listbox inwhich all items in that control are check every 30mins. If during that period time it finds an error, that same timer causes the text in the listbox to blink. The issue I'm having is, that this color change is going on every second and causing a blinking on the control. Now I've read articles on double buffering to fix this issue, but have yet to find a single one that works. The best I've gotten it was that one item, other than the item(s) that are supose to blink, will blink every second which isn't as bad as all items but is very very annoying. Here is the code....any ideas?
This is how I draw the text:
<br />
private void listBox1_DrawItem(object sender, DrawItemEventArgs e)<br />
{<br />
e.DrawBackground(); <br />
e.DrawFocusRectangle();<br />
if( listBox1.Items[ e.Index ] is Server )<br />
{<br />
Server server = (Server)listBox1.Items[e.Index];<br />
<br />
if( server.Error )<br />
{<br />
if( blinking )<br />
e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Red,<br />
new Point(e.Bounds.X,e.Bounds.Y));<br />
else<br />
e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
new Point(e.Bounds.X,e.Bounds.Y));<br />
}<br />
else<br />
e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
new Point(e.Bounds.X,e.Bounds.Y));<br />
}<br />
else <br />
e.Graphics.DrawString( listBox1.Items[e.Index].ToString(), myFont, Brushes.Black,<br />
new Point(e.Bounds.X,e.Bounds.Y));<br />
}<br />
The timer:
<br />
private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)<br />
{<br />
timer1.Stop();<br />
bool blink = false;<br />
<br />
for( int i=0; i<listBox1.Items.Count; i++ )<br />
{<br />
if( listBox1.Items[i] is Server )<br />
{<br />
Server server = (Server)listBox1.Items[i];<br />
if( server.Error )<br />
{<br />
if( blinking )<br />
{<br />
blinking = false;<br />
}<br />
else<br />
blinking = true;<br />
<br />
if( !blink )<br />
blink = true;<br />
listBox1.Invalidate();<br />
<br />
}<br />
}<br />
}<br />
<br />
click++;<br />
timer1.Start();<br />
Control Properties
<br />
this.DrawMode = DrawMode.OwnerDrawFixed;<br />
this.SetStyle(<br />
ControlStyles.AllPaintingInWmPaint |<br />
ControlStyles.DoubleBuffer |<br />
ControlStyles.Opaque , true ); <br />
Adding ControlStyles.UserPaint causes the control to go completly black.
Any help would be great!
Thanks
|
|
|
|
|
Hello everyone. I am writing a bot for a game ( the game runs in windowed mode so I think what I need is possible ) anyway I need some way to detect key presses or mouse clicks when my program doesn't have focus. To make macros and what not ( I'll also need a way to send key and mouse clicks ), I figure this is probably in user32.dll or something but I can't find any good API documentation and was hoping someone could point me in the right direction for this.
Thanks in advance!
|
|
|
|
|
|
Hey thanks this looks great for the detection of events. Any ideas on how to create and send my own events from the program. ( Even better if I can send just those events to a process without having to have that process in focus but that I'm not sure is possible )
|
|
|
|
|
Just my opinion, but C++/Win32 would probably be better suited to this project.
I have recently began to program in C++, and it is alot more flexible than C#.
In C++, you could get the handle to the game window, and send messages directly to the program, such as key press, mouse, etc...
There is an article on that here: http://www.codeproject.com/threads/sendmsg.asp
And there is a free C++/Win32 IDE here:
http://www.borland.com/downloads/download_cbuilderx.html
Good luck with your bot! What game are you making it for?
|
|
|
|
|
Thanks for the response, the bot is a trading bot for Magic Online. C++ is my primary languange anyway so I'll look into that. I was mainly going for c# since it's quicker and easier to make interfaces ( I hate MFC ) I suppose I could write it in both and have the c# run the c++ program which I've done in the past but it seems like most things one can do in c++ should be possible in c# I'll have to do a bit more research.
|
|
|
|
|
Maybe it would be easier to write a C++ dll that the C# program can use.
|
|
|
|
|
take a look at this function:
SendMessage and examine related functions - PostMessage, SendNotifyMessage etc.
____________________________________________
Robin Panther http://www.robinland.com
|
|
|
|
|
I'm making a custom text control and opted to use GDI's TextOut over GDI+ DrawString due to its more accurate spacing between letters. I got it all working how I wanted, but after using it for a while I get an out of memory exception and I'm not sure why. I know its this procedure since changing it to the gdi+ drawstring thats in the framework stops this from happening. The drawstring procedure I made along with the dllimports are as follows:
[DllImport("gdi32.dll")] <br />
static extern bool TextOut(IntPtr hdc, int nXStart, int nYStart, string lpString, int cbString); <br />
<br />
[DllImport("gdi32.dll")] <br />
static extern int SetTextColor(IntPtr hdc, int crColor); <br />
<br />
[DllImport("gdi32.dll")] <br />
static extern int SetBkColor(IntPtr hdc, int crColor); <br />
<br />
[DllImport("gdi32.dll")] <br />
static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); <br />
<br />
public static void DrawString(ref Graphics g, string s, Font Font, Color ForeColour,Color BackColour, Point point) { <br />
IntPtr hdc = g.GetHdc(); <br />
IntPtr fntOld = SelectObject(hdc, Font.ToHfont()); <br />
<br />
SetTextColor(hdc, RGB(ForeColour)); <br />
SetBkColor(hdc, RGB(BackColour)); <br />
TextOut(hdc, point.X, point.Y, s, System.Text.Encoding.Default.GetByteCount(s)); <br />
SelectObject(hdc, fntOld); <br />
g.ReleaseHdc(hdc); <br />
}
The graphics object that gets sent to the procedure is just e.Graphics from the controls paint event.
Any ideas as to why this happens would be greatly appreciated.
Draders
I figured out the problem, I needed to give Font.ToHfont() its own IntPtr and then delete it after i'm done with it using the DeleteObject GDI method.
-- modified at 11:21 Friday 24th February, 2006
|
|
|
|
|
Hi All,
I'd like to build a C# organizer application with winforms and some kind of database in the back. Is it possible to build it in a way that will not require some database system installed on each computer that the application will be distributed to. Or it defintely needs either sql server or oledb, etc? Any oppinion will be greately appreciated.
|
|
|
|
|
You can just use an MS Access database, which is simply a file so you won't need a server installed on each computer and you can just distribute it with the application. However, you do need the Access driver installed, but I am pretty sure this comes with windows.
Wacky waving inflateable arm flailing tube man!
- Family Guy
|
|
|
|