|
The following code shows "Column1" as column caption.
Why ?
How to force DataGrid to display "Caption" as column caption ?
using System.Windows.Forms;
using System.Data;
static class Program {
static void Main() {
Application.Run(new Frm());
} }
class Frm : Form {
public Frm() {
DataTable dt = new DataTable();
DataColumn column = new DataColumn();
column.Caption = "Caption";
dt.Columns.Add(column);
DataGrid dg= new DataGrid();
this.Controls.Add(dg);
dg.SetDataBinding(dt, "");
} }
Andrus
|
|
|
|
|
The DataGrid uses the DataColumn's ColumnName as the column caption. The ColumnName defaults to Column1, Column2, etc., so that's why the code shows "Column1" as the caption. If you set the DataColumn's ColumnName to "Caption", then that will be the caption displayed in the DataGrid.
|
|
|
|
|
The following code causes error in Update() line
Npgsql.NpgsqlException was unhandled by user code
Why exception is not catched ?
catch MUST catch all exceptions!
------ code:
int RowsUpdated;
try {
RowsUpdated = datapter.Update(changes);
}
catch {
System.Windows.Forms.MessageBox.Show("error");
transact.Rollback();
throw;
}
error message details are:
Npgsql.NpgsqlException was unhandled by user code
Message="ERROR: 23505: duplicate key violates unique constraint \"konto_pkey\""
Source="Npgsql"
BaseMessage="duplicate key violates unique constraint \"konto_pkey\""
Code="23505"
Detail=""
ErrorSql="update \"firma1\".\"konto\" set \"kontonr\" = '2', ....
File="nbtinsert.c"
Hint=""
Line="277"
Position=""
Routine="_bt_check_unique"
Severity="ERROR"
Where=""
StackTrace:
at Npgsql.NpgsqlConnector.CheckErrors() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlConnector.cs:line 359
at Npgsql.NpgsqlConnector.CheckErrorsAndNotifications() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlConnector.cs:line 410
at Npgsql.NpgsqlCommand.ExecuteCommand() in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 1479
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior cb) in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 633
at Npgsql.NpgsqlCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior cb) in c:\Desenvolvimento\NpgsqlBuildOficial2.0\src\Npgsql\NpgsqlCommand.cs:line 601
at System.Data.Common.DbDataAdapter.UpdateRowExecute(RowUpdatedEventArgs rowUpdatedEvent, IDbCommand dataCommand, StatementType cmdIndex)
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows, DataTableMapping tableMapping)
Andrus
|
|
|
|
|
The error should be getting caught, but is getting rethrown in the throw; line.
Are you certain it's not getting caught and rethrown? If not, then it's as if your application isn't running that code.
|
|
|
|
|
AndrusM wrote: Why exception is not catched ?
catch MUST catch all exceptions!
Did the message box show up?
After the message box is shown you rethrow (throw in C# without an exception object in side a catch block compiles to the MSIL rethrow operation) which takes the exception and continues to unwind the stack with it.
Also, if you need to rollback a transaction, it would be better to do that before having the process wait on user input because then you start locking other people out of parts of the database until the user responds.
|
|
|
|
|
Hello friends
Happy new year!
There is a project that is needed to match signature of different person,Is there any component for C# that can do it?(If you recomend a free one,It is better!)
Thanks!
|
|
|
|
|
Most signature recognition systems work on how the signature is generated. It captures input from a special stylus and records information such as direction, speed and pressure.
|
|
|
|
|
Greetings!
I want to create project with video abilities.
Here is short description of my needs:
Application needs to be done with .NET Framework.
Application should consist from two parts:
Client application and server application have different functionality, but they both should work with web-cams installed on their sides (client and server sides).
First part is a client application.
Client application can connect to different web – cams and see content of web – cam.
User of client application can talk to server application using microphone and listens answer from server user.
Except this, client application should have ability to save video from server side.
Server application should have similar video abilities with client application.
I analyzed different technologies for my purpose and I lost one's the head in technologies.
Please suggest me what technology best suites for my project.
Thank you all for your attention for my question
Best Regards,
Alex
|
|
|
|
|
Video capturing will likely require use of DirectShow, which is a native C++ framework, now part of Microsoft's native Platform SDK.
However, search the articles on this site, you should find some DirectShow wrappers for use with .NET projects. It might suit your needs.
|
|
|
|
|
Thank you a lot of for your help!!!
|
|
|
|
|
Hi,
I made an even handler for removed rows in the datagridview.
The datagridview gets its data from an xml file. When a row is removed in the datagridview, the row should be removed in the dataset as well.
This is my event handler in constructor:
this.grdTest.RowsRemoved += new DataGridViewRowsRemovedEventHandler(grdTest_RowsRemoved);
This is the code in that event handler:
void grdTest_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
{
DataSet ds = new DataSet();
ds.ReadXml("Test.xml");
foreach (DataRow dr in ds.Tables[0].Rows)
{
string remove = dr["Row"].ToString();
DataRow[] temprows = ds.Tables[0].Select("Row = " + remove);
if (temprows[0].RowState == DataRowState.Deleted)
{
ds.Tables[0].Rows.Remove(temprows[0]);
}
//if (dr.RowState == DataRowState.Deleted)
//{
// ds.Tables[0].Rows.Remove(dr);
//}
}
ds.Dispose();
}
This is how the xml file looks like:
<?xml version="1.0" encoding="UTF-8" ?>
- <Root>
- <Column>
<Row>test1</Row>
</Column>
- <Column>
<Row>test2</Row>
</Column>
- <Column>
<Row>test3</Row>
</Column>
- <Column>
<Row>test4</Row>
</Column>
</Root>
When i try to start the proram, it gives me this error:
Cannot fine column [test1].
In this line:
DataRow[] temprows = ds.Tables[0].Select("Row = " + remove);
I've tried almost everything to fix this.
I'm running out of ideas...
Can somebody help me with this problem?
Thanks in advance!
|
|
|
|
|
Which line is the error occurring on? (hint: use the debugger to see this info, or look at the stack trace of the error being thrown)
|
|
|
|
|
Hi,
I posted the line too.
In this line:
DataRow[] temprows = ds.Tables[0].Select("Row = " + remove);
By the way, is this the way to do the thing i wanna do correct?
|
|
|
|
|
Hi
I have a problem of filling null value in the column.
I have written the following query,
select c.column_name,t.constraint_type from all_cons_columns c, user_constraints t where t.table_name=c.table_name and c.table_name='student'
student table
student id - primary key
studentname - varchar
but the oracle query returns only the column having primary or foreign key. not returing the studentname. i want student name also with constraint type=null
we can do this is sql server by isnull(c.constraint_type,'')
but how to do the same in oracle? Any one help me please.........
kesavan
|
|
|
|
|
Since this is a database-specific question, you might want to try asking in the ADO/ADO.NET forum, or optionally, in an Oracle-specific forum.
|
|
|
|
|
Scenario: In general user will take database backup from database server to local system (local copy of database). User perform some changes to his local copy of database based on his requirement. Again user connects back to database server and click on update, local database should update to server database by informing each record status to the user. ex: record 1 updated / call closed do you want to update?
Here local database is going to be Pocket pc database and server database is on SQLDatabase. Can any one suggest best way to implement this feature in Windows Pocket pc, c#. I would appreciate your reply.
Thanks,
|
|
|
|
|
Well, this is not an easy task, I don't think. There are some companies that exist solely to do database synchronization, and they charge a good amount of money to these complicated tasks. Extended Systems, for example, is a company that does database synchronization between different databases, including mobile and server databases.
If you're really interested in doing this yourself, and both mobile database and server databases have the same schema (i.e. same tables, views, etc.) one possibility that comes to mind is you could save each database command you issue. When you go to update the other database, issue those commands against the other database.
I'm not really sure how well that'd work, haven't really thought it through, just an idea.
|
|
|
|
|
hi, everyone
i have a windows service which is trigerred by a timer to perform certian action(parse a xml file and insert into database).
i used a timer time interval to 1 sec( i cannot increase it)
and then i used getfile(dir) to get all files from directory. what happened is that after avery one sec the same file is updated in the database.
so i am thinking of having a thread which can stop timer and start it self and then before aborting the thread enable the timer again. and during the lifespan of thread perfrom the requierd tass?? is it poosible if yes can u just provide
an algorithm to do it.
thank you
hope to hear soon.
|
|
|
|
|
Hi Justin. I hate your music.
Can you better describe your problem? You said the same file is updated in the database -- is that a problem? When do you want the file to be updated in the database? Only when it changes?
|
|
|
|
|
I have a JPEG file with the standard tags that i want to show the picture in C#.net. Does .Net support this kind of format? How?
|
|
|
|
|
You should be able to use a PictureBox control for it.
Some people have a memory and an attention span, you should try them out one day. - Jeremy Falcon
|
|
|
|
|
I think I couldn't explain my problem in a good way. I mean I have a binary file which contains the information of a jpeg file (with its header and everything). How can I show it in a picture box in C#.NET? I mean how can I convert it to a file with JPG extension in order to be able to assign it to the image property of a picture box?
|
|
|
|
|
Image.FromStream or Image.FromFile will take care of many formats, including JPEG.
Luc Pattyn
|
|
|
|
|
I think I couldn't explain my problem in a good way. I mean I have a binary file which contains the information of a jpeg file (with its header and everything). How can I show it in a picture box in C#.NET? I mean how can I convert it to a file with JPG extension in order to be able to assign it to the image property of a picture box?
|
|
|
|
|
Bitmap bm = new Bitmap(filepath);
should do it. Then, you can assign that bitmap to a picturebox ( which is good for limited showing of bitmaps ), or you can handle your paint event and draw it yourself.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|