|
Hi,
I am have to use Sybase database in my appliction.
Is there any way to use it without installing ODBC Driver on each machine, I mean like is there any way to directly connect to Sybase by imporing a reference dll or something.
Thank you!
"Mess with the Best, Die like the rest"
|
|
|
|
|
Well, you could TRY to use the OleDb methods, but they're not going to support SyBase the best since they're kind of "generic". Other than that, you have no choice but to install the driver, or use a different database, like SQL Server or Access, that comes with the drivers already installed.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If now OleDb wht other choice do i have, since i am using a IVR system that only deployes Sybase as their database.
Thank You!
"Mess with the Best, Die like the rest"
|
|
|
|
|
M. Nauman Yousuf wrote: since i am using a IVR system that only deployes Sybase as their database.
The only other choice you have is to install the drivers.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I'm trying to create an application where i can browse the Active Directory OU folder structure. I need to select an OU and need the OU name for a next action in the application.
Any help is welcome.
Roland
|
|
|
|
|
|
Already found some information like this below, but it doesn't show any results:
mports System
Imports System.DirectoryServices
Public Class Form1
Class DirLister
Shared Sub Main(ByVal args() As String)
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://192.168.1.1")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = ("(objectClass=computer)")
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
Form1.Text = (resEnt.GetDirectoryEntry().Name.ToString())
Next
End Sub
End Class
|
|
|
|
|
Replace this line :
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://servername/DC=DCNAME, DC=local")
hopes it helps,
Wachill
Signature has been encrypted
|
|
|
|
|
That didn't work either, i also changed it after your suggestion into:
Imports System
Imports System.DirectoryServices
Public Class Form1
Class DirLister
Shared Sub Main(ByVal args() As String)
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://mydomain.local/RootDSE")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = ("(objectClass=computer)")
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
Form1.Text = (resEnt.GetDirectoryEntry().Name.ToString())
Next
End Sub
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Do i forgot something? I just want to test this with display the results at my empty form and work from there with the results.
Roland
|
|
|
|
|
Can you tell me what is not working correctly. Is it that you are not getting the required results or that you are getting an error message.
Signature has been encrypted
|
|
|
|
|
Ummm... To be frank, you're copying and pasting code that you don't understand at all, and I'm not talking about the directory searching code. It's this
Form1.Text = blah, blah, blah
in int your Main. The search code may actually be working, but since you put all this in the Main method, before the form even shows on the screen, you'll never see the results. And, the Text property of the Form just changes the TitleBar text. It doesn't show up in the form itself.
Get rid of Main method and move it into the Form_Load event. Add a ListBox to the Form and expand it to cover the form. Then change the code in the Form_Load event:
Dim enTry As DirectoryEntry = New DirectoryEntry("LDAP://your AD server/AD path to search")
Dim mySearcher As DirectorySearcher = New DirectorySearcher(enTry)
mySearcher.Filter = "(objectClass=Computer)"
Dim resEnt As SearchResult
For Each resEnt In mySearcher.FindAll()
ListBox1.Items.Add(resEnt.GetDirectoryEntry().Name)
Next
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you, i got it working with your supplied code. Just need some finetuning now, but this is working.
Roland
|
|
|
|
|
I also got i working with a treeview and a OU list. I changed:
ComboBox1.Items.Add(resEnt.GetDirectoryEntry().Name)
into:
TreeView1.Nodes.Add(resEnt.GetDirectoryEntry().Name)
The problem now is that i only see a list of OU's and not into a real treeview.
So i see:
OU1
OU2
OU3
OU1a
OU1b
Instead of:
- OU1
- OU1a
- OU1b
etc.
How can i get this working?
Roland
|
|
|
|
|
Your searching the entire subtree under the starting container. Don't.
The trick is to populate only the top level of the treeview, putting a dummy child under each leaf so you get the little plus sign next to it. Upon the user clicking each node, you have to requery AD to get the containers under that particular node, and fill in the nodes under the node that was clicked.
Didn't think this was going to be that complicated, did you?
-- modified at 17:59 Sunday 18th March, 2007
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You are right, I didn't think that it is this complicated. I'm trying to get it working, but not with any succes. Do you have some code examples so that i could get this working?
Thanks,
Roland
|
|
|
|
|
I found the code below, but when putting this into a form, i get some errors.
The code i use:
Imports System.DirectoryServices<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
Private sRootDSE As String<br />
#Region " Windows Form Designer generated code "<br />
<br />
Public Sub New()<br />
MyBase.New()<br />
<br />
'This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
<br />
'Add any initialization after the InitializeComponent() call<br />
sRootDSE = GetRootDSE()<br />
End Sub<br />
<br />
'Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
<br />
'Required by the Windows Form Designer<br />
Private components As System.ComponentModel.IContainer<br />
<br />
'NOTE: The following procedure is required by the Windows Form Designer<br />
'It can be modified using the Windows Form Designer.<br />
'Do not modify it using the code editor.<br />
Friend WithEvents TreeView1 As System.Windows.Forms.TreeView<br />
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub<br />
InitializeComponent()<br />
Me.components = New System.ComponentModel.Container<br />
Dim resources As System.Resources.ResourceManager = New<br />
System.Resources.ResourceManager(GetType(Form1))<br />
Me.TreeView1 = New System.Windows.Forms.TreeView<br />
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)<br />
Me.SuspendLayout()<br />
'<br />
'TreeView1<br />
'<br />
Me.TreeView1.ImageList = Me.ImageList1<br />
Me.TreeView1.Location = New System.Drawing.Point(32, 24)<br />
Me.TreeView1.Name = "TreeView1"<br />
Me.TreeView1.Size = New System.Drawing.Size(240, 248)<br />
Me.TreeView1.TabIndex = 0<br />
'<br />
'ImageList1<br />
'<br />
Me.ImageList1.ImageSize = New System.Drawing.Size(16, 16)<br />
Me.ImageList1.ImageStream =<br />
CType(resources.GetObject("ImageList1.ImageStream"),<br />
System.Windows.Forms.ImageListStreamer)<br />
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent<br />
'<br />
'Form1<br />
'<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(552, 302)<br />
Me.Controls.Add(Me.TreeView1)<br />
Me.Name = "Form1"<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
<br />
End Sub<br />
<br />
#End Region<br />
<br />
Sub GetOU()<br />
<br />
Dim root As New DirectoryEntry("LDAP://" & sRootDSE)<br />
<br />
Dim searcher As New DirectorySearcher(root)<br />
<br />
Dim s As SearchResult<br />
Dim nodearr() As TreeNode<br />
searcher.SearchScope = SearchScope.OneLevel<br />
Dim I As Integer<br />
Dim cp As IComparer<br />
cp = New NodeComparer<br />
<br />
ReDim nodearr(searcher.FindAll.Count - 1)<br />
<br />
For Each s In searcher.FindAll<br />
Dim no As New TreeNode(s.GetDirectoryEntry.Properties("Name").Value.ToString, GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString), GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString))<br />
no.Tag = s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString()<br />
nodearr(I) = no<br />
<br />
I += 1<br />
Next<br />
Array.Sort(nodearr, cp)<br />
<br />
Dim k As TreeNode<br />
<br />
TreeView1.Nodes.AddRange(nodearr)<br />
<br />
End Sub<br />
<br />
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
GetOU()<br />
End Sub<br />
<br />
Private Sub TreeView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles TreeView1.DoubleClick<br />
<br />
If TreeView1.SelectedNode.GetNodeCount(True) < 1 Then <br />
Dim root As New DirectoryEntry("LDAP://" & TreeView1.SelectedNode.Tag.ToString)<br />
Dim searcher As New DirectorySearcher(root)<br />
Dim s As SearchResult<br />
Dim nodearr As TreeNode()<br />
searcher.SearchScope = SearchScope.OneLevel<br />
Dim I As Integer<br />
Dim cp As IComparer<br />
cp = New NodeComparer<br />
<br />
ReDim nodearr(searcher.FindAll.Count - 1)<br />
<br />
For Each s In searcher.FindAll<br />
Dim no As New TreeNode(s.GetDirectoryEntry.Properties("Name").Value.ToString, GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString), GetObjectClass(s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString))<br />
no.Tag = s.GetDirectoryEntry.Properties("DistinguishedName").Value.ToString()<br />
nodearr(I) = no<br />
I += 1<br />
Next<br />
Array.Sort(nodearr, cp)<br />
TreeView1.SelectedNode.Nodes.AddRange(nodearr)<br />
TreeView1.SelectedNode.Expand()<br />
End If<br />
<br />
End Sub<br />
<br />
Private Function GetRootDSE() As String<br />
<br />
Dim RootEntry As New DirectoryEntry("LDAP://RootDSE")<br />
Return RootEntry.Properties("DefaultNamingContext").Value.ToString<br />
'Add error handling<br />
End Function<br />
<br />
Private Function GetObjectClass(ByVal DN As String) As Integer<br />
Dim m As New DirectoryEntry("LDAP://" & DN)<br />
<br />
Dim r As New DirectoryEntry(m.NativeObject.schema.ToString)<br />
<br />
Select Case r.Name<br />
Case "organizationalUnit"<br />
Return 0<br />
Case "computer"<br />
Return 1<br />
Case "user"<br />
Return 2<br />
Case Else<br />
Return 0<br />
End Select<br />
End Function<br />
<br />
End Class<br />
Class NodeComparer<br />
Implements IComparer 'Implement the IComparer Interface<br />
Overloads Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare<br />
Return CType(x, TreeNode).ImageIndex - CType(y, TreeNode).ImageIndex<br />
End Function<br />
End Class
The errors i get at VB 2005 Express Edition:
Error 1 'Protected Overrides Sub Dispose(disposing As Boolean)' has multiple definitions with identical signatures. Line 7 Column 29
Error 2 'components' is already declared as 'Private Dim components As System.ComponentModel.IContainer' in this class. Line 28 Column 13
Error 3 'TreeView1' is already declared as 'Friend Dim WithEvents TreeView1 As System.Windows.Forms.TreeView' in this class. Line 33 Column 23
Error 4 Identifier expected. Line 35 Column 58
Warning 5 Unused local variable: 'k'. Line 97 Column 13
What is going wrong?
Roland
|
|
|
|
|
This code is used for making a custom control. You really don't want to to use it unless you're making your own.
And yes, it IS that complicated. No, I don't have any example code for doing this.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I dont know how to open the existing pdf file(out side of the form) in visual basic.
I used shell command, but one problem happened. While first pdf open means it is not opened, while openning second pdf file on the same run time the first file ans second file both are opened.I dont know y this problem.
Also how to search particular word in PDF using VB code?. I need both answers. I am very much struglling bcoz of this.
My advance Thanks For that Guy.
|
|
|
|
|
There are free and commerical PDF libraries for .NET. There is no PDF support built in, Process.Start to start a viewer is the best you can hope for, or perhaps using IE as a control to view them.
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 )
|
|
|
|
|
If you convert the date into a DateTime object, there is a DayOfWeek property in the DateTime that you can check to see if it is Sunday. It returns a enumeration.
Dim dt As New DateTime(2003, 5, 1)
If dt.DayOfWeek = DayOfWeek.Sunday Then
End If
Hope that helps.
Ben
|
|
|
|
|
thanks lot,
its working cool..........,
Magi
|
|
|
|
|
hi frnds,
i hv a form with textboxes, radio buttons, tabcontrols and panel(pnlCommand)which holds button(btnReply)
on Form1_Laod tabcontrol's visbility is false
on Form1_Resize code i hv wrriten which works fine
Me.Size = New System.Drawing.Size(760, 280)
pnlCommand.Size = New System.Drawing.Size(712, 40)
pnlCommand.Location = New System.Drawing.Point(40, 200)
bt on btnReply the form shld increase the size i.e
tabcontrols shld be made visible and btnReply shld be placed at bottom af the form
thnxs in advance
Pushpa
|
|
|
|
|
Use the Anchor property to set where controls move on a resize of the form, and set the Size property, as you already are, to resize 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 )
|
|
|
|
|
Hi
when the user press Enter key on datagridview the focus goto the next row , ant Tab key go to the next cell ..
How can I prevent that to use Entyer/Tab keys in any other use ..
jooooo
|
|
|
|
|
you can use the keypress event of the datagridview.
check which key was pressed.if enter key then move the focus to the previous row and if tab key then move the focus to the previous cell.
hopes it helps,
Wachill
Signature has been encrypted
|
|
|
|