|
Generally in Connection string we will give the path as
Data source="D:\xyz.mdb"
In VB we will write the same code as
Data Source=" & App.Path & "\DC.mdb"
How to set the same datsource in VB.Net
Waiting for ur reply
Thanks in advance
Priya
|
|
|
|
|
Environment.CurrentDirectory
However, be aware that this can be changed during run time.
|
|
|
|
|
How many times are you going to ask the same question??
The VB.NET equiv is:
Dim dataSource As String = Path.Combine(Application.StartupPath, "DC.MDB")
This is the first time I'm going to disagree with Colin. I don't like using CurrentDirectory because its a path that can change during the exeuction of your code. Just ask anyone who has ever used the OpenFile and SaveFile Dialog boxes incorrectly...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi friends i couldnot find any tools for creating frames in vb.net..please give me your valuable suggestion...
jeyan
|
|
|
|
|
what do you mean with frames? A rectangle, A panel object? If you be specific, I will help you.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
|
Okay here is the method how to set background color for selected cells in a datagridview control.
DataGridView1.SelectionMode = DataGridViewSelectionMode.CellSelect
Dim I As Int32 = 0
For I = 1 To DataGridView1.SelectedCells.Count
DataGridView1.SelectedCells(I).DataGridView.BackgroundColor = Color.Aqua
Next
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Hello,
[2005]
I have a datagrid that is bound to a typed dataset. I have a combo box that is bound to the same typed dataset.
The user will select from the combo a category the bindingsource will filter only the categories that the user wants displayed in the datagrid.
However, i have button called reset, which should display everything back into the dataset. However, it doesn't do this. I have checked to see how many record are contained in the dataset after the reset button is clicked during the debugger and the number of rows is correct.
The dataset are filled during the form load and when the user clicks the reset button
I know that everytime the dataset gets filled, it is cleared and filled automatically, so I don't understand why this would happen. My code is below. Thanks for any advice on this code.
'Load categories into equipment category combo box<br />
Private Sub LoadCategories()<br />
Try<br />
Me.cboCategory.DataSource = Me.DsAddComponetAndEquipment1.SoftwareCategory<br />
Me.cboCategory.DisplayMember = "Category"<br />
Me.cboCategory.ValueMember = "CategoryID"<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub
'Load all the components into the grid<br />
Private Sub LoadAllSoftware()<br />
Try<br />
Me.TA_Software_dsComponent_Equipment1.Fill(Me.DsAddComponetAndEquipment1.Software)<br />
Me.dgvSoftware.DataSource = Me.DsAddComponetAndEquipment1.Software<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub
'Reload all software<br />
Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click<br />
Me.LoadAllSoftware()<br />
End Sub
'Display what the user has selected from the category of sofware<br />
Private Sub cboCategory_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCategory.SelectionChangeCommitted<br />
Dim bsCategory As New BindingSource<br />
<br />
Try<br />
bsCategory.DataSource = Me.DsAddComponetAndEquipment1.Software<br />
bsCategory.Filter = String.Format("CategoryID = {0}", Me.cboCategory.SelectedValue)<br />
<br />
Me.dgvSoftware.DataSource = bsCategory<br />
<br />
Catch ex As Exception<br />
MessageBox.Show(ex.Message)<br />
End Try<br />
End Sub
Thanks very much for your time,
Steve
|
|
|
|
|
Hi Steve,
First thing that comes to mind with your code (although it hasn't got anything to do with the problem) is that you really don't have to use me. everywhere, and MessageBox.Show doesn't need .Show .
As for the actual problem though:
steve_rm wrote: 'Load all the components into the grid
Private Sub LoadAllSoftware()
Try
Me.TA_Software_dsComponent_Equipment1.Fill(Me.DsAddComponetAndEquipment1.Software)
Me.dgvSoftware.DataSource = Me.DsAddComponetAndEquipment1.Software
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
You could try:
<br />
dgvSoftware.DataSource = DsAddComponetAndEquipment1<br />
dgvSoftware.DataMember = "Software"<br />
or alternatively you could try:
<br />
dgvSoftware.SetDataBinding(DsAddComponetAndEquipment1, "Software")<br />
steve_rm wrote: [2005]
I take it that you mean that you are using .NET 2005? Unfortunately my boss doesn't want to invest in the upgrade yet, so I am still looking at it from the .NET 2003 point of view. Therefore it is ofcourse possible that my code doesn't apply for your environment anymore, but otherwise, are you sure that .fill actually empties the dataset first before filling it again? For me that doesn't work, I still need to call DataSet1.clear() first.
Now if binding works when your form is loaded, than maybe you should think of doing the .fill thing only once (at the beginning), copy the whole dataset into a temporary dataset, and just copy the temporary ds back to your main ds when the user presses the reset button.
The active data binding should take care of the rest.
Hope this is of use to you,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
Thanks for your reply and advice.
Steve
|
|
|
|
|
I'm using this
rtbText.SaveFile(currentFile, Word.WdSaveFormat.wdFormatDocument)
it saves it ok but when I try to open it in word it ask if it can install a converter I click No then the document is shown but now whan I click save it ask tells me that it will save it as a text document.
All I want to do is save the text in the .doc format, why is it proving so difficult?
|
|
|
|
|
Anybloodyid wrote: All I want to do is save the text in the .doc format, why is it proving so difficult?
Because the RichTextBox can't save anything in Word's .doc format! The RTB doesn't know anything about it. All it can do is save as straight text or RichTextFormat, or RTF.
Word can load either type of document, but it'll ask you which format you want to resave it in when you go to do so.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
So basically there are three options open word, save doc, close word.
Open word, save as RTF.
Don't bother with word.
|
|
|
|
|
Yep.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well, it's done, I can finally save a word document from my application
And then open it in word as a word.doc.
|
|
|
|
|
Actually, you saved an RTF file with a .doc file extension. It's not really a Word document. It's just in a format (RTF) that Word happens to know how to load and interpret.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
So, what you're saying is that when I write a document in MS word and do a SaveAs and choose.Doc, it actually saves it as an Rtf and sticks on a .Doc extension.
What's the point of that?
I might as well save in another format called .Mxt (My Extension)
|
|
|
|
|
I thought you were saving this out of a RichTextBox. In that case, an RTB only knows two formats: Text and RTF.
If you're saving out of Word, it'll save in its own proprietary format, with the .doc extension, RTF, Formatted and Unformatted Text, HTML, and a few others.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes that's it, I copy to clipboard, open word, paste and save, but I now do it without having the SaveAs dialog from word opening.
|
|
|
|
|
i have added a text file in my project.
hw can i make the opening of text file under a click event as we do in forms
dim a as new form
a.show()
|
|
|
|
|
mns01 wrote: hw can i make the opening of text file under a click event as we do in forms
What exactly do you mean by that? A text file is somewhat inert. You need something to perform an action on the text file. The text file itself cannot do anything on a click event.
|
|
|
|
|
You need to write a form which loads the text file from the resources and shows it.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
You're kidding me?
|
|
|
|
|
Nope - the C++/CLI forum tends to attract standard C++ questions from people who are, well, new. They don't know what C++/CLI is, and perhaps get confused by the 'visual C++' forum's name.
But, this was definately a standout classic.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i dnt knw wats wrong wid ya people...
this problem is as simple as opening a new form when we click a button.
its jst nw in place of form v have a text file , which i have already added by 'adding new object' option....
its jst that i dnt knw the procedureand m askin is it possible or not..
|
|
|
|