|
Which version of Visual Studio?? In 2005 (.NET Framework 2.0) you just have to change the BackColor property of the ToolStrip object to the color you want.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi all,
Can anybody send me the code to list out all the oracle servers in the network and all the oracle databases in a particular server. I mean, i need to do it through ODBC. The code for doing the same for SQL is as follows,if possible pls point out what all changes I need to add to get the oracle list, i have tried out the "DRIVER= Oracle ODBC Driver" change.That is not working.
'code starts here
'Note : Include "DRIVER= Oracle ODBC Driver" for the SQL_DRIVER_STR variable in the code below and try it.
'class file
Imports System
Imports System.Data.SqlClient
Imports System.Text
Imports System.Runtime.InteropServices
Public Class SqlServersDatabases
#Region "ODBC32 API"
Private Const SQL_HANDLE_ENV As Short = 1
Private Const SQL_HANDLE_DBC As Short = 2
Private Const SQL_ATTR_ODBC_VERSION As Integer = 200
Private Const SQL_OV_ODBC3 As Integer = 3
Private Const SQL_SUCCESS As Short = 0
Private Const SQL_NEED_DATA As Short = 99
Private Const DEFAULT_RESULT_SIZE As Short = 1024
Private Const SQL_DRIVER_STR As String ="DRIVER=SQL SERVER"
<dllimport("odbc32.dll")> Private Shared Function SQLAllocHandle(ByVal hType As Short, ByVal inputHandle As IntPtr, ByRef outputHandle As IntPtr) As Short
End Function
<dllimport("odbc32.dll")> Private Shared Function SQLSetEnvAttr(ByVal henv As IntPtr, ByVal attribute As Integer, ByVal valuePtr As IntPtr, ByVal strLength As Integer) As Short
End Function
<dllimport("odbc32.dll", charset:="CharSet.Ansi)"> Private Shared Function SQLBrowseConnect(ByVal hconn As IntPtr, ByVal inString As StringBuilder, ByVal inStringLength As Short, ByVal outString As StringBuilder, ByVal outStringLength As Short, ByRef outLengthNeeded As Short) As Short
End Function
<dllimport("odbc32.dll")> Private Shared Function SQLFreeHandle(ByVal hType As Short, ByVal handle As IntPtr) As Short
End Function
#End Region
'Lists SQL Server databases
'usage: comboBox1.Items.AddRange(SqlServersDatabases.Servers())
Public Shared Function Servers() As String()
Dim retval As String() = Nothing
Dim txt As String = String.Empty
Dim henv As IntPtr = IntPtr.Zero
Dim hconn As IntPtr = IntPtr.Zero
Dim inString As New StringBuilder(SQL_DRIVER_STR)
Dim outString As New StringBuilder(DEFAULT_RESULT_SIZE)
Dim inStringLength As Short = Fix(CShort(inString.Length))
Dim lenNeeded As Short = 0
Try
If SQL_SUCCESS = SQLAllocHandle(SQL_HANDLE_ENV, henv, henv) Then
If SQL_SUCCESS = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION, New System.IntPtr(SQL_OV_ODBC3), 0) Then
If SQL_SUCCESS = SQLAllocHandle(SQL_HANDLE_DBC, henv, hconn) Then
If SQL_NEED_DATA = SQLBrowseConnect(hconn, inString, inStringLength, outString, DEFAULT_RESULT_SIZE, lenNeeded) Then
If DEFAULT_RESULT_SIZE < lenNeeded Then
outString.Capacity = lenNeeded
If SQL_NEED_DATA <> SQLBrowseConnect(hconn, inString, inStringLength, outString, lenNeeded, lenNeeded) Then
Throw New ApplicationException("Unabled to aquire SQL Servers from ODBC driver.")
End If
End If
txt = outString.ToString()
Dim start As Integer = txt.IndexOf("{") + 1
Dim len As Integer = txt.IndexOf("}") - start
If start > 0 AndAlso len > 0 Then
txt = txt.Substring(start, len)
Else
txt = String.Empty
End If
End If
End If
End If
End If
Catch ex As Exception
txt = String.Empty
Throw ex
Finally
If Not hconn.Equals(IntPtr.Zero) Then
SQLFreeHandle(SQL_HANDLE_DBC, hconn)
End If
If Not henv.Equals(IntPtr.Zero) Then
SQLFreeHandle(SQL_HANDLE_ENV, hconn)
End If
End Try
If txt.Length > 0 Then
retval = txt.Split(",".ToCharArray())
End If
Return retval
End Function
Public Shared Function Databases(ByVal ConnectionString As String) As ArrayList
Dim retval As New ArrayList
Dim SqlConObject As SqlConnection
Dim SqldaObject As SqlDataAdapter
Dim SqlTblObject As DataTable
SqlConObject = New SqlConnection(ConnectionString)
SqldaObject = New SqlDataAdapter("SELECT name FROM sysDatabases", SqlConObject)
SqlTblObject = New DataTable
SqldaObject.Fill(SqlTblObject)
For i As Int16 = 0 To SqlTblObject.Rows.Count - 1
retval.Add(SqlTblObject.Rows(i).Item(0).ToString())
Next
SqlTblObject.Dispose()
SqldaObject.Dispose()
Return retval
End Function
End Class
SYAMLAL
|
|
|
|
|
Can anyone give a web site that tell about all connection string?
Thanks
................
|
|
|
|
|
|
Check these links:
1) http://connectionstrings.com/
2) http://www.carlprothman.net/Default.aspx?tabid=81
SYAMLAL
|
|
|
|
|
i have already knew, but how can i use SQL statement/
thanks
................
|
|
|
|
|
I need to have an introduction and sufisant explaining on how i can work on the workflow and how it benifit me
Thanks in advance
Assaf
|
|
|
|
|
I'm not sure what you mean ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
How can I use MHFlexiGrid with editing properties?I want to use this MHFlexiGrid as the front of a database.Please help me.
sadat
|
|
|
|
|
VB6 I guess ? Please don't ask the same thing twice.
AFAIK, you need to extend the MSFlexGrid to support editing.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
How can I use MHFlexiGrid with editing properties?I want to use this MHFlexiGrid as the front of a database.Please help me.
|
|
|
|
|
Sir.Madam,
I wanted to add a new property into the combo box.But before that ,I tried to write Inherits System.Windows.Forms.ComboBox.But that is creating a problem.
Base class System.Windows.Forms.ComboBox specified for component1 cannot be different from base class System.ComponentModel.Component of one of its other partial types.
I am creating a component class to do this.
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
I guess what you need is an user control...
Shreekar
|
|
|
|
|
will u please help me out of my problem.?
|
|
|
|
|
Pankaj,
If you're using Visual Studio 2005, you'll notice that when you create for example, a component class, 2 files will be generated. One of the files, the one named YourComponent.Designer.vb is the one used by the designer. If you look into this file you'll find your problem. This file is the one containing the inherit sentence, and by default it comes with System.ComponentModel.Component.
If you just change this with System.Windows.Forms.ComboBox, your component will work perfectly.
Hope it works!
Gonzalo
Gonzaling
|
|
|
|
|
Hi everybody. I already design one project, but now i want to rename it to an other name. how can i do? thank beforehand.
|
|
|
|
|
Can't you right click on the name, and see a rename option ?
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
how i will generate auto number from particular number like 108 to 200 using xsl?
veerabagu
|
|
|
|
|
You want to specify two numbers and get back a sequence, using XSL ? Why ? We have an XML/XSL forum, BTW.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
I have two for loops from which I am displaying the folder items in a table.
i.e. from outer for loop I am displaying the folder names and from inner loop
I am displaying the contents of that folders .
Now I want to do paging since in case of hundreds and thousands of msgs in my inbox.
So I think datagrid is the best option for tht
but I am getting how to populate the datagrid according to this and do paging in tht.
|
|
|
|
|
your datagrid can be told to handle paging for you. If you build an array or list of the items you want to display, you can use that as a datasource.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
The VB.NET code for displaying folder in an HTML table is:
'Looping all the subfolders
For j = 1 To 2
sfolder = oFol.Item(j)
s.WriteLine(sfolder.Name)
'Looping the Mailitems of the Subfolders with the sender's name, Subject,Recevied Time,Size of the mail
Dim i As Integer
For i = oItems.Count To 1 Step -1
s.WriteLine(oMail.Subject)
Next
Next
How can I make an array or list of the items and display it to datagrid and allow paging.
|
|
|
|
|
Create a list first, then instead of calling writeline, add the items to your list. Of course, this will give you a list, not a tree.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|
|
That's the problem that i am not getting how to make an array or list from these for loops and populate the items into the datagrid to do further formatting like paging and all!
I want the exact look like a mailbox i.e. when we click on the folder name then the respective folder contents should be displayed in the datagrid with paging.
|
|
|
|
|
bhavna816 wrote: I want the exact look like a mailbox
OK, then you really want to use a repeater or a grid control, not a dataview, because you want to expand and contract groups.
At the most basic level
Dim items as List<string> = new List<string> ' who knows what brackets VB uses ?
'Looping all the subfolders
For j = 1 To 2
sfolder = oFol.Item(j)
items.Add(sfolder.Name)
'Looping the Mailitems of the Subfolders with the sender's name, Subject,Recevied Time,Size of the mail
Dim i As Integer
For i = oItems.Count To 1 Step -1
items.Add(oMail.Subject)
Next
Next
myDataGrid.DataSource = items
myDataGrid.DataBind()
This will just give you a list. You'd need to create a list of a struct or something to store more info, like waht is a folder. Then you've have to write the code to render it accordingly.
Christian Graus - C++ MVP
'Why don't we jump on a fad that hasn't already been widely discredited ?' - Dilbert
|
|
|
|