|
Do I have to open and close the database connection when using TableAdapters like I would with DataAdapters?
|
|
|
|
|
Hi,
No, TableAdapters will manage this for you!
regards,
|
|
|
|
|
I am writing a VB.net application. I learned using dataAdapters and the configuration wizard in Visual Basic 2003, but I am using VB 2005 to write my program. Being I am using 2005 I used the wizard to create a TableAdapter. Then I created a module to declare some variables in because I have multiple forms in the application.
Here is my problem.
After I declared the variables in the module I am not able to use .Fill in my forms to Fill the DataTable.
When I create a TableAdapter do I also have to create a DataTable?
Here is the variable declarations I am using in the module.
' declare variables<br />
Dim dataSet As New DataSet1()<br />
Dim hoursTableAdapter As New DataSet1TableAdapters.tbl_hoursTableAdapter()
Here is the code I am trying to use to access the TableAdapter (from within one fo the forms), but when I use it I get the blue squigly line under the code. The blue squigly line shows up under "Me.hoursTableAdapter" and "Me.DataSet".
Me.hoursTableAdapter.Fill(Me.DataSet.tbl_hours)
How do I access the TableAdapter?
I tried Importing the namespace from the table adapter as well. Here is the code I used to import the namespace. I put it before the class declaration.
Imports lessonProgram.DataSet1TableAdapters
|
|
|
|
|
I figured out the problem. I had to drag and drop the table from the Data Sources tab.
|
|
|
|
|
Hi,
I am making a HTML Editor in VB.NET using a WebBrowser as a WYSIWYG Editor. This is the code I use:
Me.WebBrowser1.Document.DomDocument.designMode = "On"
That works fine, and I also use exccommand to allow movement of elements, etc. My problem is that no matter what I rty, I cannot make HTML table cells/rows/columns resizable, and I cannot make the user able to select multiple cells. This doesn't happen even if I use a normal webbrowser not in designmode! I know that this is possible because most WYSIWYG editors, eg frontpage, expression web, allow you to do all this, but I just cannot figure out how to manage it in my application.
Does anyone know a way of doing any of these things with a WebBrowser in VB.NET? I don't mind if i only get an answer to one of the above.
Conor
|
|
|
|
|
Hi there...
I got a bit of a problem with coloring text between two given words. Here's an example:
I have a RichTextBox with the following text:
This is a RichTextBox with some random jibberish bla bla bla i just need to make it long enough.
Next, i have two other textboxes with the following text in the first textbox:
with
and in the second textbox:
jibberish
Below that, i have two more textbox with the following text in the first:
just
and in the second textbox:
long
Now when your press a button, i want the text between those words colored red, so that result will be like this:
Click here to see the required result
As you can see, the text between the given words are colored red.
I need this so i can colorize error messages in my app. My app handles somekind of compilation process and at the end it shows the compile log of the compilation process to the user. If the log has errors, i want to make the error messages red, so that it is easy to find.
Now there are many different kinds of error messages that can pop up during this compile process, so i need to find a way to handle all those error messages (making them red) with as less code as possible. Perhaps an Array will do the job?
Can anyone help me with these issues? I hope you guys understand what i need.
http://www.themightyatom.nl
|
|
|
|
|
General strategy might be to loop through each of the words in the long string. When the first word of the desired red string is found then find the position in the string of the first letter of that word and remember it. When the second word is found then find the position of the last letter of that word. At this point select the text between the first position and the second position and color it red... then continue.
I noticed that you can't repeat the same word as the first or last word in the desired string or you'll get a problem.
for instance:
"I want to have this code be the selected code" (in red)
"I, code" creates a problem
cs
|
|
|
|
|
Uhm... ok. Ill try it out but i don't think ill be able to get it to work though. This is kinda difficult.
http://www.themightyatom.nl
|
|
|
|
|
I'd suggest doing anything like colouring when you're adding the text to the control, not afterwards. Then it's much easier to identify the string you're adding, so you don't have to search for words or worry about whether the 'end words' in your error message will be found somewhere else in the control and make your code 'find' the wrong stuff.
I'd also suggest using a new line for each message, and maybe starting the lines with some standard bit that indicates whether they're errors, warnings, or something else.
This would identify the errors by something other than colour, which is often a good idea.
If "rich text" includes tables, then 'message type' could be column 1 and the detail would go in column 2.
|
|
|
|
|
Hmmm, to tell you the truth, im not really sure if i can do all that, im still a beginner Vb'er, you see. This sounds kind of advanced and difficult (for me that is).
Maybe you can provide me with an example or something that i can work out?
Ill include your name in my app when i release it.
http://www.themightyatom.nl
|
|
|
|
|
I've never used rich text boxes for serious work, but:
The control should have facilities for setting the "selection" (the equivalent of the currently selected text in Word, Notepad or anything between) and for formatting the selection. When you add text to the end of the control you may well find that the added text is the selection, or can be made to be the selection as part of the adding process.
You need to look for documentation about using the control, and/or some sample applications using it. Googling for
rich text "visual basic" sample
should find you lots of stuff.
(preferably replace "visual basic" with something like "visual basic 2005" to identify the version you're using).
|
|
|
|
|
Ill try that, thanks.
http://www.themightyatom.nl
|
|
|
|
|
Just curious...
With New Form1<br />
.Property<br />
.Method<br />
End With
It creates a variable that is automatically released when the "end with" is encountered.
Any known memory leak doing this?
Thanks,
Nathan
|
|
|
|
|
Hi,
AFAIK the With construct is just a shorthand notation, it does not "release" anything,
so if the object needs disposing of closing you should call Dispose() or Close() explicitly
when you no longer need it, to avoid memory leaks.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
in this context it would be "released" because it's a block variable. when the block is done the variable is released. i agree property clean up needs to be done just curious if this something that while dotnet allows isn't handled properly (memory leak).
|
|
|
|
|
No,
(I am assuming the .Method you called is not Close)
once the with block ends, the way you wrote it the object can no longer be accessed
since you don't hold a reference to it, but that does not mean the object also gets
removed from memory at that time; the garbage collector will take care of that at its
leasure, it is allowed to do so immediately but will not do so unless it needs free
memory due to some other request(s). In the mean time any resources (managed or unmanaged)
remain allocated.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I suggest you do some reading on the core of .NET.
Nice to see VB finally has this sort of syntax, it took you guys a while.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm very fimilar with vb so what do you suggest I look at - the 'core' is a little vague.
baby steps baby steps
|
|
|
|
|
Hi Christian,
the with statement "executes a series of statements on a single object" and exists
in VB6 and probably even more ancient versions too, but it does not resemble the
using statement we all enjoy in C#, it is just a shorthand avoiding the repetition
of the object's name in every line, as in
With MyLabel
.Height = 2000
.Width = 2000
.Caption = "This is MyLabel"
End With
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi Nathan,
There's no memory leak in your code. After your code leaves the With block, there are no live references to the Form1 instance, so eventually the garbage collector will kick-in and release both memory & native windows resources associated with the form (.net forms and controls are actually wrappers of native windows resources).
When this collection actually happens, is not under your control, unless you call GC.Collect(); however this is not something recommended since it prevents the garbage collector to self-tune adequately to your application's memory consumption rate - in simpler words - even though by calling GC.Collect() all "releasable" memory is reclaimed and released *at your request*, this is a very expensive operation and in the end you might hurt your application's performance very badly.
However, I would suggest calling .Dispose() before leaving the with block. This way you will be releasing the form's wrapped native windows resources early (something advisable since windows resources are limited). Keep in mind that even if you call Dispose(), the memory held by the Form1 instance will not be freed until the garbage collector runs and reclaims it.
Sincererly I hope I have clarified your doubt and not confused you more.
Gerardo
|
|
|
|
|
|
Hello,
I need a commandbutton that i colored red or green to blink.
Does anyone know how i can do this ?
Is this a standard function in VB 2005.
Thanks
Didier
|
|
|
|
|
|
Use a system timer that changes the color of the button at time intervals you specify.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Can I make a chart in Visual Basic 6 in a form.
What kind of reference must I use?
I don't want to make it myself, I mean drawing it myself.
|
|
|
|