|
tims81 wrote: but it still only shows the first row selected but then continues from the original row when using the arrow keys. did your code still work after trying a sort operation like:
You're right! It showed the highlighting on the correct row, but the focus-rectangle for keyboard-input was still on the last row. In order to "force" the correct focus, I changed the example-code to this;
private void Form1_Load(object sender, System.EventArgs e)
{
DataTable dt = new DataTable("employee");
dt.Columns.Add("firstname");
dt.Columns.Add("lastname");
dt.Rows.Add("john", "doe");
dt.Rows.Add("johnny", "walker");
dataGridView1.DataSource = dt;
dataGridView1.Sort(dataGridView1.Columns[1], ListSortDirection.Descending);
}
void HandleClick(object sender, EventArgs e)
{
dataGridView1.ClearSelection();
if (dataGridView1.Rows.Count > 0)
{
dataGridView1.Rows[0].Selected = true;
dataGridView1.CurrentCell = dataGridView1.Rows[0].Cells[0];
}
}
Hope this helps
I are Troll
|
|
|
|
|
It works now! That's so awesome. Thank you so much for your help, I owe you one!!!
|
|
|
|
|
You're welcome
I are Troll
|
|
|
|
|
Pelase help,
I want to write some data to Contactless Smartcard Mifare DESFIRE ev1,
using Smartcard writer/reader is ACS ACR122.I use C# to write the application
This is a example of data that want to write :
1. Name
2. DOB
3. etc
My question is : how to create the file structure of the data?
Regard,
Mashudi
thanks
|
|
|
|
|
have you found any solution by now ?
|
|
|
|
|
Hello I would like to ask how to I get this error
below here is the code
Dim con As New OleDb.OleDbConnection<br />
Dim inc As Integer<br />
Dim MaxRows As Integer<br />
Dim ds As New DataSet<br />
Dim da As OleDb.OleDbDataAdapter<br />
Dim sql As String<br />
<br />
<br />
<br />
Private Sub Sampler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _<br />
"Data Source = c:\Sadsign.mdb"<br />
con.Open()<br />
<br />
sql = "SELECT * FROM Names"<br />
da = New OleDb.OleDbDataAdapter(sql, con)<br />
<br />
<br />
da.Fill(ds, "contacts")<br />
'con.Close()<br />
'MaxRows = ds.Tables("contacts").Rows.Count<br />
'inc = -1<br />
<br />
End Sub
my error is in "da.fill" command and the error is
"IErrorInfo.GetDescription failed with E_FAIL(0x80004005)"
Thanks,
dfan23
|
|
|
|
|
Try putting square brackets around Names . 'Name' is a reserved word in Access. 'Names' may be, I'm not sure. I don't use Access for any database work.
If your database does not have any security setup in it in Access, you may also want to chagne the connection string to read:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Sadsign.mdb;User Id=admin;Password=;
If you DO have security setup, look at these[^] examples of connection strings.
|
|
|
|
|
Hello,
Thanks for the immediate response sir.
Now I know that Name/Names are not valid as variable names.
If would you mine sir I would like to ask how to add a new row
to my database then how to update the changes made into the database
Thanks,
dfan23
|
|
|
|
|
try this:
Dim con As New OleDb.OleDbConnection
Dim inc As Integer
Dim MaxRows As Integer
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim sql As String
Dim dt As DataTable
Private Sub Sampler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ds = new DataSet("dataSet");
dt = new DataTable("Contacts");
ds.Tables.Add(dt);
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source = c:\Sadsign.mdb"
con.Open()
sql = "SELECT * FROM Names"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(dt, "contacts")
'con.Close()
'MaxRows = ds.Tables("contacts").Rows.Count
'inc = -1
End Sub
|
|
|
|
|
Hello sir,
I would like to thanks for the immediate response
but I still have error when I try your code
I still got this error
"Object is not an ADODB.RecordSet or an ADODB.Record. Parameter name: adodb"
I'm a bit confuse now or anything coz I think the codes is right
by the way sir I am using visual studio team system 2008
and microsft access 2007 as my database.
Thanks,
dfan23
|
|
|
|
|
OK. use this code:
Private Sub Sampler_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ds = New DataSet("dataSet")
dt = New DataTable()
ds.Tables.Add(dt)
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" + _
"Data Source = c:\Sadsign.mdb"
con.Open()
sql = "SELECT * FROM [Names]"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(dt)
'con.Close()
'MaxRows = ds.Tables("contacts").Rows.Count
'inc = -1
End Sub
seems that "Names" is a reserved keyword. Hence the error.
|
|
|
|
|
Hello,
Thanks for the immediate response sir.
Now I know that Name/Names are not valid as variable names.
If would you mine sir I would like to ask how to add a new row
to my database then how to update the changes made into the database.
I have a code for adding a new row but still got error in updating it.
The Error is "Syntax error in INSERT INTO statement."
below here is my code:
da = New OleDb.OleDbDataAdapter(sql, con)
cb = New OleDb.OleDbCommandBuilder(da)
Dim newRow As DataRow
newRow = ds.Tables("employeeTable").NewRow
ds.Tables("employeeTable").Rows.Add(newRow)
newRow.Item("Position") = comboPosition.Text
newRow.Item("Last_Name") = txtLastName.Text
newRow.Item("First_Name") = txtFirstName.Text
da.Update(ds, "employeeTable")
Thanks,
dfan23
|
|
|
|
|
dfan23 wrote: Now I know that Name/Names are not valid as variable names.
Is your problem sorted? then rate the answer.
dfan23 wrote: If would you mine sir I would like to ask how to add a new row
to my database then how to update the changes made into the database.
I have a code for adding a new row but still got error in updating it.
Looks to me that you should read some textbooks for this...or atleast google how to work with datatables.
here is an nice link that i learnt from... guess u would like it too. http://www.dotnetfunda.com/articles/article131.aspx[^]
|
|
|
|
|
Hello, sorry for reposting this
Thanks for the immediate response sir.
Now I know that Name/Names are not valid as variable names.
If would you mine sir I would like to ask how to add a new row
to my database then how to update the changes made into the database.
I have a code for adding a new row but still got error in updating it.
The Error is "Syntax error in INSERT INTO statement."
below here is my code:
<pre>da = New OleDb.OleDbDataAdapter(sql, con)
cb = New OleDb.OleDbCommandBuilder(da)
Dim newRow As DataRow
newRow = ds.Tables("employeeTable").NewRow
ds.Tables("employeeTable").Rows.Add(newRow)
newRow.Item("Position") = comboPosition.Text
newRow.Item("Last_Name") = txtLastName.Text
newRow.Item("First_Name") = txtFirstName.Text
da.Update(ds, "employeeTable")</pre>
Thanks,
dfan23
|
|
|
|
|
Buddy there can be many things wrong here.
You haven't created a commandbuilder here.
commandbuilder can only work when there is a primary key in the database.
Why don't you read some books before posting these kind of questions here. These are one of the most basic questions available in any textbook which teach VB.net with SQL
any code which works with sql will work with msAccess too except for using a OleDbConnection instead of SqlConnection
|
|
|
|
|
Hello,
thanks for the help I kindly appreciate your suggestions,
I have read some vb.net books but some are using the drag and
drop system , but I wanted to try also coding all the connections.
Thanks again,
dfan23
|
|
|
|
|
|
Hello,
Thanks for your help and suggestion.
|
|
|
|
|
I have a VB.Net application that references a DLL written in VC++. This is a critical application and must run. Sporadically (about once a week) the application generates a message with the app name as title with the text "<app> has encountered a problem and needs to close..." and the buttons "Debug" and "Close" at the bottom. The problem here is that I need to know that the application has generated the message so that I can kill it and restart it immediately. I have tried to send a message to an auxilliary application that monitors the main app, but since it is in a timed loop, the message is sent even if the debug message is shown, so as far as the aux. app is concerned, everything is just fine.
I have disabled the JIT debug script and tried everything I know of to get around this. It seems that Microsoft insists on giving you a message whether you want it or not.
Sitting and waiting for the error to occur is not an option and the log files I have put into the program don't tell me what stopped it. The DLL is the source of the problem.
What I need is a way of disabling the runtime debug message so that the program just dies, so it can be detected and restarted, or barring that, a way of having a separate program detect that the main program has entered into this state, so it can be killed and restarted.
Note: If you are going to mention the painfully obvious and tell me that I should fix the DLL, trust me - I've tried and will keep trying. You'll be wasting your time and mine. I just need an interim solution that will keep the application running. TIA
|
|
|
|
|
|
He said not to mention the painfully obvious
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Now that i think of it, "painfully obvious and tell me that I should fix the DLL" seems to be a good idea
|
|
|
|
|
To both of you:
Actually, the code has try...catch structures everywhere. It had been working for a year when the first problem occurred. All attempts to duplicate it here have failed because we don't have the money to duplicate the hardware. Extra log messages have been introduced, but don't point to the problem. The reason just fixing the dll is not a viable option is that it would required me waiting on site for one to two weeks until the error happened again, if at all - again, no money for that. Remote login is not possible.
The problem may have something to do with the fact that try...catch doesn't work with WIN32 exceptions starting with VS 2005.
I must say, this forum used to have people who actually tried to help. Your petty sarcasm is both uncalled for and counter-productive. If you are incapable of offering anything positive, please don't answer at all.
|
|
|
|
|
fdmaxey wrote: I must say, this forum used to have people who actually tried to help. Your petty sarcasm is both uncalled for and counter-productive. If you are incapable of offering anything positive, please don't answer at all.
Hi,
I would like to offer a Sorry for being sarcastic... but your question didn't sound as serious/clear/professional as your this comment. It sounded like someone has made a program, got it installed and just cannot handle it.
Anyways. there are only two solutions that I can think of.
1. Adding try/catch block in your main method. If at all any error happens, it should be caught within main method.
2. http://msdn.microsoft.com/en-us/library/d21c150d.aspx[^] It talks about how to disable exception methods.
Other than these, i cannot think of an other options. Sorry... May be someone else can improve on this answer.
|
|
|
|
|
Hi,
I need my .net application written in vb.net to communicate to or process a application that runs on a mainframe system. Is there any possibility in achieving this? I need no API to be involved or any other services such as CICS/HIS or socket programming.
Thanks in advance.
|
|
|
|