|
hai iam having two tables having a field id , the id should exist in the first table and it should not exist in the second table.i have used reader to check the first table(when id exists in the first table it should move to next table) and then i moved to the second table but its giving an error that reader is already open,first close the reader how to handle it?
|
|
|
|
|
This error comes because reader works in connected mode.
Sol 1:
You have to make two connection objects use first connection object to read using data reader and insert using the other connection object.
Sol 2:
Use a datatable and insert all the data from data reader to a datatable.
Now close data reader and now make a loop on datatable get every record and insert into next table.
(if u want to check id of record from the first table and then insert into second table then these are the solutions else please explain this question)
Do good and have good.
|
|
|
|
|
i have to check 1st table and then validate the 2nd table and then only i have insert so i have to use three connection object isit right,can we go for reader inside a reader and how to close the reader by reader.
|
|
|
|
|
Hi i think you can also use dataset containing those tables. try that
|
|
|
|
|
I am using a Thread.Abort to abort an SQL command when the user wants to stop the current execution of an SQL Command.
However, it seems to take a while for the ThreadAbortException to start up and cancelling the current execution. So I am wondering what takes place when the Thread.Abort that makes the SQL takes about 10-15 seconds to allow it to go towards the ThreadAbortException.
-- modified at 22:56 Thursday 23rd February, 2006
|
|
|
|
|
ThreadAbort can abort threads only when they are running managed code. When you called the method to abort the command, it probably was executing unmanaged code.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
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?
|
|
|
|