|
The same as doing it with a collection of strings or any other source. You supply the code to write one record at a time to the database, then just call it repeatedly for each string or other data you have.
There a TONS of examples all over the web on how to work with databases in VB.NET. Google results for "vb.net write data to database[^]"
|
|
|
|
|
thanks for your reply.
i tried the sites you suggested but there is code for vb only. i could not find code for vb express.
please adivse.
|
|
|
|
|
There is no difference between the two. The language is the same.
|
|
|
|
|
I'm trying to detect if my ATL control is installed on the users system in IE8. There seems to be a functional difference between the two implementations below. The first always returns "true" (even if control is uninstalled), while the second seems to detect the case where my control is not installed, however it raises IE8 security prompts ("Are you sure you want to run this control?"). Ideally, I just want to know if the control is installed or not so i can prompt a download if needed. Can anyone help?
function DetectActiveX (controlName)
on error resume next
dim res
res = 0
if IsObject(CreateObject(controlName)) then
res = 1
end if
DetectActiveX = res
end function
function DetectActiveX (controlName)
on error resume next
dim tControl
dim res
res = 0
set tControl = CreateObject(controlName)
if IsObject(tControl) then
res = 1
end if
DetectActiveX = res
end function
I know about the codebase attribute, but I don't want to use it as testing has proven its very slow to refresh after install.
Thanks,
Chris
|
|
|
|
|
How about checking for an error, not an object, after you try and create it?
On Error Resume Next
Set tControl = CreateObject(controlName)
If Err.Number <> 0 Then
' Your control probably isn't installed...
End If
|
|
|
|
|
Hi,
Thanks for your reply. I tried your err.Number suggestion. However, I get error #429 "activeX component can't create object" both when the control is not installed and when the control is installed but IE8 hasn't "approved" it to run yet.
My concern is that the end user will see two infobar prompts, one to download the installer and one to Run the control, when in-fact they may have already downloaded and installed the control via another browser/process.
I'm looking for a way to detect the difference between these two cases so i don't prompt for a download every time.
Thanks,
Chris
|
|
|
|
|
In that case, you'd probably want the Web Development forum.
|
|
|
|
|
Any help in general would be appreciated, I need to build a control array at run time, so as an example I can do something like this
Private Sub createlblSlotArray()
Dim i As Short
ReDim lblSlot(3)
For i = 1 To 3
lblSlot(i) = New System.Windows.Forms.Label
With lblSlot(i)
.Tag = i
AddHandler .Click, AddressOf Me.lblSlot_click
End With
Next
Me.Controls.AddRange(lblSlot)
lblSlot(1).Location = New System.Drawing.Point(50, 50)
lblSlot(2).Location = New System.Drawing.Point(100, 70)
lblSlot(3).Location = New System.Drawing.Point(100, 90)
End Sub
I need to add a popup menu to each of these labels, when the user right clicks on a label, I need to know which one the right click was on, set a variable so it can be used later, then show the context menu.
would I use the form1_click?
Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Label1.MouseDown
' what to do here to get the label? this seems to be tied to only the first label?
End Sub
can you show me an example of how to handle events from a control array of this nature, also, if I do not know how many context menu items I will have until run time, so I am not sure how to do that, the popup menu click event appear to be tied to the exact item that was selected.
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
' this is OK for menu item 1, how do I deal with new items I may add at run time?
End Sub
thanks in advance
No-e
|
|
|
|
|
If you are handling the MenuItem click event, then you can get the control name using MenuItemName.GetContextMenu().SourceControl .
In order to attach a click event to the dynamic menuitem, use MenuitemName.Click += new EventHandler(EventHandlerName) .
जय हिंद
|
|
|
|
|
Thanks, but I not quite following you. When the user selects a menu item from context menu, I how do I determine what item they selected? What event do I look for and how do I grab the item?
No-e
|
|
|
|
|
Each menuitem has a Click event. You will need to handle that. Object sender in the definition will tell you all about the clicked menuitem.
जय हिंद
|
|
|
|
|
There are no control arrays in .NET and no need for them. You handle the Click event of the label, not the form. The ending part of the function header of the event handler just needs to be modified so it can handle the Click event of all of your label controls. You can do that by adding the name of each label and it's event name to the Handles clause:
Private Sub Labels_Click(blah, blah) Handles Label1.Click, Label2.Click, Label3.Click
Then, if the handler code, the label that was clicked will be in the sender argument passed to your event handler.
Alternatively, you can even skip the Handles clause and wire up the event handlers yourself using AddHandler.
|
|
|
|
|
Dave's one of the brightest minds on the boards here, but I'm going to disagree with him slightly.
You can have an array of an labels and setup everything dynamically. Is this the preferred way of doing things the majority of the time? NO. Most of the time you don't need to do this; however, sometimes forms or controls need to built and set dynamically (IE: dynamic menus, reporting forms, etc).
If you really need this functionality, create the array of labels and link them with the addhandler. As Dave mentioned, you can have one event that handles all the click events for the controls. Parse on the control name or whatever else you need to do to perform the correct function from within the event that is shared amongst all the label controls.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Jon_Boy wrote: but I'm going to disagree with him slightly.
All I said was there was no need for the control array, not the dynamic creation of controls.
When the labels click events are all wired up to the same handler, he'll get the instance that was clicked in the sender argument in the handler.
I think we're on the same page, but maybe not. I just can't see the difference.
|
|
|
|
|
Roger that gold leader. I misconstrued your reply.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
Hi CP ,
I am using the Property grid in my application .Lets consider [None] has to appear if i set the property to empty.
Consider VB6.0 application to understand clearly .
Lets consider the Image property of Picture box. I set the image from My Documents. THen at the Image property i pressed the DEL key from keyboard .Directly it has to show the [None] as property text bcoz there is no image for the Picture box.
How to achieve this Functionality in Propertygrid ??
Regards,
|
|
|
|
|
If I understand what you want correctly, you don't handle the Key events of the propertygrid, but create a custom UITypeEditor for your property and handle the keypress in that.
|
|
|
|
|
Hi Dave,
Thanks for reply.
May i know how can i implement in custom UITypeEditor ???
Regards
|
|
|
|
|
Google for "UITypeEditor VB.NET" and you'll find examples. There's just too much information to stick in a forum post.
|
|
|
|
|
Some of my users are using Outlook. And few are don't using outlook. So which is the best way?
And I checked the following the mail is not going.Showing failure() error.!
Where is the mistake, I can't understand.
Thanks
Dim myMailMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage("vip@gmail.com", "my_companymail@mycompany.com")
myMailMessage.IsBodyHtml = False
Dim MailAuthentication = New System.Net.NetworkCredential("vip@gamil.com", "mypassword")
Dim MailClient As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient("www.gmail.com", 25)
MailClient.EnableSsl = True
MailClient.UseDefaultCredentials = False
MailClient.Credentials = MailAuthentication
MailClient.Send(myMailMessage)
|
|
|
|
|
Paramu1973 wrote: Some of my users are using Outlook. And few are don't using outlook. So which is the best way?
None really, its just a preference.
Paramu1973 wrote: And I checked the following the mail is not going.Showing failure() error.!
What error? Is there any more information provided?
Check to see if the smtp server (www.gmail.com) is accessible from the computers where you get the error.
trying filling in the subject line (sometimes its needed from what I can remember)
|
|
|
|
|
You may want to check that server name again. I doubt the GMail uses the "www..." address as it's SMTP server. It's probably closer to "smtp.gmail.com".
|
|
|
|
|
Here are all the settings you need for making both client and servers for use with gmail.
Incoming Mail (POP3) Server - requires SSL: pop.gmail.com
Use SSL: Yes
Port: 995
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587
Account Name: your full email address (including @gmail.com or @your_domain.com)
Email Address: your email address (username@gmail.com or username@your_domain.com)
Password: your Gmail password
Note the choice of ports on the sending of email, previously when i have tested this, i have had to switch ports.
|
|
|
|
|
hi all ,
am using vb.net 2.0 , when am adding new report to my application at the debugging time it gives reference error
<br />
Error 1 The "ResolveAssemblyReference" task failed unexpectedly.<br />
System.IO.PathTooLongException: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.<br />
at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)<br />
at System.IO.Path.GetDirectoryName(String path)<br />
at Microsoft.Build.Tasks.SystemState.FileExists(String path)<br />
at Microsoft.Build.Tasks.Resolver.FileMatchesAssemblyName(AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, Boolean allowMismatchBetweenFusionNameAndFileName, String pathToCandidateAssembly, ResolutionSearchLocation searchLocation)<br />
at Microsoft.Build.Tasks.Resolver.ResolveAsFile(String fullPath, AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, Boolean allowMismatchBetweenFusionNameAndFileName, ArrayList assembliesConsideredAndRejected)<br />
at Microsoft.Build.Tasks.Resolver.ResolveFromDirectory(AssemblyNameExtension assemblyName, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String directory, ArrayList assembliesConsideredAndRejected)<br />
at Microsoft.Build.Tasks.DirectoryResolver.Resolve(AssemblyNameExtension assemblyName, String rawFileNameCandidate, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String hintPath, String assemblyFolderKey, ArrayList assembliesConsideredAndRejected, String& foundPath, Boolean& userRequestedSpecificFile)<br />
at Microsoft.Build.Tasks.AssemblyResolution.ResolveReference(IEnumerable`1 jaggedResolvers, AssemblyNameExtension assemblyName, String rawFileNameCandidate, Boolean isPrimaryProjectReference, Boolean wantSpecificVersion, String[] executableExtensions, String hintPath, String assemblyFolderKey, ArrayList assembliesConsideredAndRejected, String& resolvedSearchPath, Boolean& userRequestedSpecificFile)<br />
at Microsoft.Build.Tasks.ReferenceTable.ResolveReference(AssemblyNameExtension assemblyName, String rawFileNameCandidate, Reference reference)<br />
at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryAssemblyReferenceItem(ITaskItem referenceAssemblyName)<br />
at Microsoft.Build.Tasks.ReferenceTable.SetPrimaryItems(ITaskItem[] referenceAssemblyFiles, ITaskItem[] referenceAssemblyNames, ArrayList exceptions)<br />
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute(FileExists fileExists, DirectoryExists directoryExists, GetDirectories getDirectories, GetAssemblyName getAssemblyName, GetAssemblyMetadata getAssemblyMetadata, GetRegistrySubKeyNames getRegistrySubKeyNames, GetRegistrySubKeyDefaultValue getRegistrySubKeyDefaultValue, GetLastWriteTime getLastWriteTime)<br />
at Microsoft.Build.Tasks.ResolveAssemblyReference.Execute()<br />
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode howToExecuteTask, Hashtable projectItemsAvailableToTask, BuildPropertyGroup projectPropertiesAvailableToTask, Boolean& taskClassWasFound) AccountsBO<br />
<br />
|
|
|
|
|
Can you explain a bit more , and send the related code?
I think answer lies here:
Member 6294146 wrote: The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
Mithun Shitole
"Free Your Mind"
http://www.technoyaari.com
|
|
|
|
|