|
I think that the datagrid in question is a bit too complex for this to work. I tried what you had posted in the DataGrid1_KeyDown event...
If e.KeyCode = Keys.Delete Then.....
but I still immediately receive:
************** Exception Text **************
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Windows.Forms.DataGrid.ResetSelection()
at System.Windows.Forms.DataGrid.ResetUIState()
at System.Windows.Forms.DataGrid.SetDataGridRows(DataGridRow[] newRows, Int32 newRowsLength)
at System.Windows.Forms.DataGrid.DeleteDataGridRows(Int32 deletedRows)
at System.Windows.Forms.DataGrid.DeleteRows(DataGridRow[] localGridRows)
at System.Windows.Forms.DataGrid.ProcessGridKey(KeyEventArgs ke)
at System.Windows.Forms.DataGrid.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
at System.Windows.Forms.Control.PreProcessMessage(Message& msg)
at System.Windows.Forms.ThreadContext.System.Windows.Forms.UnsafeNativeMethods+IMsoComponent.FPreTranslateMessage(MSG& msg)
|
|
|
|
|
I am posting the full code that worked for me. it is written for a button_click event. if u want it for key_press please wait for a few days. i will ask around and tell u. the code that worked for me is:
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlDbType
Public Class Form5
Inherits System.Windows.Forms.Form
.
.
.
.
Dim dsdata2 As New DataSet
Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlcon2 As New SqlConnection(constr)
Dim sqladp2 As New SqlDataAdapter
Dim cmdstr1 As New SqlCommand
Dim strq1 As String
sqlcon2.Open()
strq1 = "select * from Doctor"
Try
sqladp2.SelectCommand = cmdstr1
sqladp2.SelectCommand.CommandText = strq1
sqladp2.SelectCommand.Connection = sqlcon2
dsdata2.Clear()
sqladp2.Fill(dsdata2, "SearchResult")
If dsdata2.Tables("SearchResult").Rows.Count > 0 Then
DataGrid1.DataSource = dsdata2
DataGrid1.DataMember = "SearchResult"
DataGrid1.Refresh()
End If
cmdstr1.Dispose()
sqlcon2.Close()
sqlcon2.Dispose()
sqladp2.Dispose()
Catch empexp As SqlException
MessageBox.Show(empexp.Message)
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If dsdata2.Tables("SearchResult").Rows.Count > 0 Then
dsdata2.Tables("SearchResult").Rows.RemoveAt(DataGrid1.CurrentRowIndex)
DataGrid1.Refresh()
Else
MsgBox("No Data To Delete")
End If
End Sub
End Class
Hope this will help u.
|
|
|
|
|
I am building a web form that connects to an Access database. When the DataAdpater tries to fill the DataTable the following error occurs:
The Microsoft Jet database engine cannot open the file 'C:\Inetpub\wwwroot\Database\InternalUseLog\db1.mdb'. It is already opened exclusively by another user, or you need permission to view its data.
I'm the only one using the database so I think I need to get permission. What do I need to do to get permission?
Thanks
|
|
|
|
|
That looks like a directory under the IIS. Are you sure your db isn't already locked up by another process? What happens if you try to open it simply with Access?
|
|
|
|
|
I ran into this problem a few years back. The issue was that the folder did not provide proper NTFS permissions to rwx the file.
Hope it helps.
|
|
|
|
|
Thanks for the help, I solved it on my own.
I had to right click on the database folder and set the Web Sharing and Security properties.
|
|
|
|
|
Very simple.
All I want is to add a summary to my function or description that will be visible when I can the function from the editor.
Like when you user the object browser and it shows you the summary of each function,How do I add this summary to the function?
Thanks a lot.
|
|
|
|
|
It's called XML Documentation.
The official help is a good source of informations.
|
|
|
|
|
I'm no referring to the:
What I want is to have the function summary display in the object browser.
For example if you select the System.URI from the object browser you will get the summary:
"Provides an object representation of a uniform resource identifier (URI) and easy access to the parts of the URI."
I want to know how to add this summary to each function or class I have.
|
|
|
|
|
That's probably the description of the class.
If you have a class with methods and properties what you call summary is probably the description of the class.
Pay attention that XML Documentation requires formally correct XML.
You can point your help to:
ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.VisualStudio.v80.en/dv_vbalr/html/27b5b06c-09b9-496a-8245-f9542d846230.htm
|
|
|
|
|
Dear friends hi I m facing a problem.I've to export result fetched by vb.net code in ms word.I did it but after quiting word in vb.net it ask me to save changes when document get loaded.if i don't close ms-word instance in vb.net code it leave a winword.exe process after i quit my program.so can u guide me how to avoid this message when document loaded.
"do u want to save changes?".
I think If i save my document before, closing it problem can be solved but I don't know how to do this.
Please help me
!!!!!!!!!!!
Thanking you !!!
Uttam kumar
be the best...
|
|
|
|
|
I really don't know how the Word works but with the MapPoint object you have a property called Saved. If you set it to True before closing it won't bother you with any request. I guess/hope there's something similar in the Word Interop. have a look at the doc.
Well I did look at the doc and easily found:
Quit: Quits Word. You can optionally save any open documents, passing a value from the WdSaveOptions enumeration: wdSaveChanges, wdPromptToSaveChanges, and wdDoNotSaveChanges. The following fragment shows all three different ways to quit Word: (...)
-- modified at 7:38 Tuesday 29th November, 2005
|
|
|
|
|
Why would Word prompt you to save while opening a file. Are you sure about the location that the message is thrown from?
My implementation of opening/closing MS Word doc from VB.NET that does not prompt for anything and does not leave a winword process running.
Dim app As Microsoft.Office.Interop.Word.Application
app = New Microsoft.Office.Interop.Word.Application
app.Visible = True
Dim doc As Microsoft.Office.Interop.Word.Document
doc = app.Documents.Open("C:\Test.doc", Type.Missing, True, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, True, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
doc.Close(False, Type.Missing, Type.Missing)
app.Quit()
|
|
|
|
|
hi dear
first of all thanks for ur quick answer!.;)
Actually I m opening a new document and then pasting my result in tabluar form.so after this if i close this then it as me for changes to be saved or not. if i save this document from vb.net then it shows me save dialog box.I want to avoid that.is there any way by which i can save my document with vb.net only.it must not pop up save dialogbox for the name.
be the best...
|
|
|
|
|
hellow to all ..
how can i count how many items i have in a datagrid when i load it ?
thxx
|
|
|
|
|
dim dv as DataView = Grid1.DataSource<br />
dim ii as integer = dv.Count
|
|
|
|
|
thxx ..
but i do not know why it is not working for me !
when i run the code i recive this error
Specified cast is not valid
-- modified at 6:57 Tuesday 29th November, 2005
|
|
|
|
|
neverminde i found a soulotion ..
dim i as integer
i = ds.Tables("tabelname").Rows.Count()
lblCount.Text = lblCount.Text & i
|
|
|
|
|
Ok, reality is that I can't get it work.
I am trying to get some data from an ACCESS database through my VB.NET desktop program.
This is what Im trying to use:
Dim ConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\administrator.RANDY\Desktop\LeadRipper2\Database\Version2.MDB"
Dim sSQL As String = "SELECT * FROM tblURL"
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sSQL, New SqlClient.SqlConnection(ConnectionString))
command.Connection.Open()
Dim dataReader As SqlClient.SqlDataReader = command.ExecuteReader(CommandBehavior.CloseConnection)
With dataReader
Do While .Read = True
MessageBox.Show(.GetString(1) & "" & .GetString(2))
Loop
.Close()
End With
I keep getting an error here:
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sSQL, New SqlClient.SqlConnection(ConnectionString))
can someone help me out please???
VB6 was SOOOO OOOOOOOOO O O O O O OO O O O much easier.
Whatever happened to ado.recordsets???
|
|
|
|
|
Desert_Dude wrote: Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sSQL, New SqlClient.SqlConnection(ConnectionString))
What's the error ? I'd be inclined to create a connection object, not just call 'new' here.
Desert_Dude wrote: VB6 was SOOOO OOOOOOOOO O O O O O OO O O O much easier.
*grin* That's because VB.NET is more like programming...
Desert_Dude wrote: Whatever happened to ado.recordsets???
ADO.NET was designed with the web in mind, and hence is a disconnected system, very different to ADO for reasons that make a lot of sense if you work on web apps.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: Desert_Dude wrote:
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand(sSQL, New SqlClient.SqlConnection(ConnectionString))
What's the error ? I'd be inclined to create a connection object, not just call 'new' here.
I have a WROX book (VB.NET Professional) and I was directly quoting their methods, trying to get the DataReader Object fired up.
Christian Graus wrote: Desert_Dude wrote:
VB6 was SOOOO OOOOOOOOO O O O O O OO O O O much easier.
*grin* That's because VB.NET is more like programming...
HEhehehe, Im cool with that. My profession is more like banking than programming. I have just enough knowledge to make myself dangerous.
I went to a community college where I got an associates in VB, Database and web design, (circa 1999-2000) and haven't touched it since.
Christian Graus wrote: Desert_Dude wrote:
Whatever happened to ado.recordsets???
ADO.NET was designed with the web in mind, and hence is a disconnected system, very different to ADO for reasons that make a lot of sense if you work on web apps.
OK, back to business. I have an Access Database on my local machine that I need to get data from. The data will include multiple records that I need to process.
i.e. SELECT * FROM tblWhatever WHERE fldSomething = "THIS" AND fldSomethingelse = "THAT"
I can work on the SQL syntax to get it to work so Im not worried about that. (yet)
This is as far as I got:
1. Create a Connection
2. Execute a command (SQL)
3. Now what?
I'd like to loop through the data so I can process it and at the same time do an UPDATE to the database.
Can you help me out with the code and syntax please?
I'd really appreciate it!!!
|
|
|
|
|
I reckon this[^] will answer your questions.
Good luck !!
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
HAHAHAHA Christian,
Not to be ungrateful for your help but, it's a day late and dollar short. LOL
I did bookmark that site though, I'm sure I will go there again... like right now to work on the XML part of what Im doing.
Thanks a million to everone who posted up for me here!
-Geoff
|
|
|
|
|
Oh, someone else helped. No worries, I'm in a different time zone, people helped you while I slept. I'm glad you got it working.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
That's because you are trying to use a SQLCommand with an Access database. Try using an OledbCommand and OledbConnection instead.
|
|
|
|