|
laura h wrote: Please respond only if you can complete this assignment immediately
ROTFL - no-one is going to 'complete your assignment' for you.
Like Dave said, all of this sucks. Create a struct that contains the two bits of data you need, and a single array of the struct. If two pieces of data belong together, put them together.
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 )
|
|
|
|
|
just wondering if anyone knows y this wont work, i want to display the tables of the database selected in the next combo box and it gets stuck on "SQLDatabase = SQLServer.Databases.Item(cboDatabases.Text)" in the button2_click procedure , prob easy i no but brain not functioning, cheers
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
Public SQLServer As New SQLDMO.SQLServer
Dim SQLDatabase As SQLDMO.Database
'UPGRADE_WARNING: Event chkNTAuthentication.CheckStateChanged may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'
Private Sub chkNTAuthentication_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkNTAuthentication.CheckStateChanged
' Enable Disable the Authentication dialog box ...
If chkNTAuthentication.CheckState = 1 Then
txtLogin.Enabled = False
txtPassword.Enabled = False
Else
txtLogin.Enabled = True
txtPassword.Enabled = True
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sqlApp As New SQLDMO.Application
Dim NameList As SQLDMO.NameList
Dim index As Integer
NameList = sqlApp.ListAvailableSQLServers
' Get the Servers on the network and display the Values into the combo
For index = 1 To NameList.Count
cboServer.Items.Add(NameList.Item(index))
Next
' Enable NT Auth by deafult.
If chkNTAuthentication.CheckState = 1 Then
txtLogin.Enabled = False
txtPassword.Enabled = False
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim SQLServer As New SQLDMO.SQLServer
On Error GoTo ErrorHandler
SQLServer.LoginTimeout = 10
' Check for the type of authentication and Logon to the Server.
If chkNTAuthentication.CheckState Then
' For Integrated NT security
SQLServer.LoginSecure = True
SQLServer.Connect(cboServer.Text)
Else
' SQL Server security
SQLServer.Connect(cboServer.Text, txtLogin.Text, txtPassword.Text)
End If
cboDatabases.Visible = True
Label4.Visible = True
Button2.Visible = True
Dim db As SQLDMO.Database
cboDatabases.Items.Clear()
' Fill the database combobox
For Each db In SQLServer.Databases
If Not db.SystemObject Then
cboDatabases.Items.Add(db.Name)
End If
Next db
' Select the first database by default
cboDatabases.SelectedIndex = 0
Exit Sub
ErrorHandler:
MsgBox(Err.Description, MsgBoxStyle.Critical, "Error - Connecting")
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim tbl As SQLDMO.Table
Dim sp As SQLDMO.StoredProcedure
cboTables.Visible = True
Label5.Visible = True
' Get a reference to the selected database
SQLDatabase = SQLServer.Databases.Item(cboDatabases.Text)
' Fill the Tables combo
cboTables.Items.Clear()
cboTables.Items.Add("(none)")
cboTables.Items.Add("(all)")
' Fill all the table looping from the SQL Object
For Each tbl In SQLDatabase.Tables
If Not tbl.SystemObject Then
cboTables.Items.Add(tbl.Name)
End If
Next tbl
cboTables.SelectedIndex = 0
End Sub
End Class
gvm
|
|
|
|
|
I have so far been using Using in the following way.
Using swOutputWriter as New StreamWriter(file, whatever)
swOutputWriter.Writeline(line)
End Using but today I saw the following
Dim swOutputWriter as StreamWriter
Using swOutputWriter
swOutputWriter.Writeline(line)
End Using Are both correct? If the 2nd is correct, is it also as safe?
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
There's actually a serious bug in the second example, but they boil down to exactly the same code:
Dim swOutputWriter As StreamWriter
swOutputWriter = New StreamWriter(file,whatever)
Using swOutputWriter
....
End Using
They are both correct and safe...
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Oh yes I missed the New portion.
Thanks...
One more though, if you create it a new instance of that object and then use the surrounding "Using/End Using" later, is that object now gone and will need to be re-instantiated?
-- modified at 12:25 Friday 20th April, 2007
CleaKO
"I think you'll be okay here, they have a thin candy shell. 'Surprised you didn't know that.'" - Tommy (Tommy Boy) "Fill it up again! Fill it up again! Once it hits your lips, it's so good!" - Frank the Tank (Old School)
|
|
|
|
|
Yep. The object that's specified on the Using line will automatically be Disposed when execution ever, for ANY reason, leaves the Using block. If you still need it beyond that, maybe you shouldn't be using Using , or you'll have to expand the scope of the Using block to encompass the code you need.
Using was put in so you didn't have to make absolutely sure you disposed an object in the event you forgot to or an error occured in your code, forcing it to take an execution path you didn't anticipate.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
what is max rows we can have on msflexgrid
Develop2Program & Program2Develop
|
|
|
|
|
Theoretically, the maximum number is the maximum long value - 2,147,483,647.
In practice, it will depend on the resources available to you - I ran a quick test and was able to get 145,000 rows.
Tim
|
|
|
|
|
The real question is why would you want to show that many? The scroll wheel on a mouse is only good for 5,000 miles.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
Hi,
I am using the following to redirect the output of a dos command to a richtextbox but anytime I try run it to get the directory listing of a large CD nothing happens but if there is only one file on the CD it works. Can anyone help.
Dim myProcess As Process = New Process
Dim prgOutput As String ' Output from DOS program
myProcess.StartInfo.FileName = "c:\dir.bat" 'Full pathname to including file name
myProcess.StartInfo.CreateNoWindow = True ' Does not create a window DOS program
myProcess.StartInfo.UseShellExecute = False ' Must be false to redirect output
myProcess.StartInfo.RedirectStandardOutput = True
myProcess.Start() ' Start the DOS program
myProcess.WaitForExit() ' Wait until it completes before moving on
prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output
rtbOutput.Text = prgOutput
I am using a .bat file which has the following commands:
@ECHO OFF
d:
dir /A /S /O:GNE
c:
Running the .bat file directly from the command prompt works on the disc with loads of files
Thanks
|
|
|
|
|
|
johnjsm wrote: myProcess.WaitForExit() ' Wait until it completes before moving on
prgOutput = myProcess.StandardOutput.ReadToEnd ' Get the DOS output
Try changing the order of these two lines
Cheers,
Suresh
|
|
|
|
|
I did what you suggested and it works. Thnaks for your help.
|
|
|
|
|
Just got VB 2005 and wonder, How do you add code snippets to the list.
Also can anyone recommend any web sites for code snippets?
Thanks
|
|
|
|
|
directred wrote: Also can anyone recommend any web sites for code snippets
All you have to do is type "vb.net 2005 code snippets" into Google.
directred wrote: Just got VB 2005 and wonder, How do you add code snippets to the list.
Have you tried typing "code snippets" into the Index tab "Look for" box in the MSDN Library installed with Visual Studio? There's tons of information on it. Index entries include "creating", "creating for XML files", "customizing", "deleting", "finding", "inserting", "managing", ... Complete with all kinds of "How To's".
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i have created a program that i can load a text file to my textbox. but i can work it out in image. any idea how to do that?thx
Don't block the drive way of all the newbies in programming. )
|
|
|
|
|
What have you tried ? You can't put an image in a textbox, but you can use Bitmap.FromFile to get a bitmap from the path selected, or FromStream if the dialog offers a stream. A picture box is the easy way to show an image.
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 )
|
|
|
|
|
ok thank you. i will try what you said. thanks again
Don't block the drive way of all the newbies in programming.
|
|
|
|
|
i use following code:
--------------------------------------
private sub ShareFolder()
Dim ct As New DirectoryEntry("WinNT://" +
SystemInformation.ComputerName + "/LanmanServer")
ct.AuthenticationType = AuthenticationTypes.Signing Or _
AuthenticationTypes.Sealing Or _
AuthenticationTypes.Secure
ct.Username = Nothing
ct.Password = Nothing
Dim shares As DirectoryEntries = ct.Children
Dim share As DirectoryEntry =
ct.Children.Add("foldersharename", "fileshare")
share.Properties("path").Add("c:\new folder")
share.CommitChanges()
end sub
-------------------------------------
After calling ShareFolder function,"c:\new folder" folder was shared.
But when opening the folder from any other computer than mine through
LAN (Local Area Network), "\\Tulgaa\foldersharename is not accessible. You
might not have permission to user this network resource. Contact the
administrator of this server ot find out if you have access
permissions" msg is thrown. When I share a folder manually from
Explorer, all is fine.
How to solve this problem, tell me please !!!
Tulgaa
-- modified at 2:33 Saturday 21st April, 2007
|
|
|
|
|
If your example code is accurate, then you've shared out the folder "C:\New Folder" with a share name of "foldersharename". You then tried to open the folder from another machine using the wrong name. You have to use the sharename in the UNC path, not the folder name.
\\server\sharename\subfolder\subfolder\file
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
i tried to open the folder from another machine using correct path which was "\\server\foldersharename" .
i'm trying to share a folder by another way. code here: >>
Sub MyShare()<br />
Dim serverName, UserName, AdminName, UserAcct As String<br />
Dim Ace1 As Management.ManagementObject<br />
serverName = SystemInformation.ComputerName<br />
Dim scope As New ManagementScope("\\" + SystemInformation.ComputerName + "\root\cimv2")<br />
Dim wmiShare As New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Share"), Nothing)<br />
UserName = SystemInformation.UserName<br />
<br />
Dim userAccount As ManagementObject<br />
Dim userExists As Boolean = False<br />
Dim userSearcher As New ManagementObjectSearcher(scope, New SelectQuery(String.Format("SELECT * from Win32_UserAccount WHERE domain='{0}'", serverName))) <br />
For Each userAccount In userSearcher.Get()<br />
If (String.Compare(UserName, userAccount("Name"), True) = 0) Then<br />
userExists = True<br />
Exit For<br />
End If<br />
Next<br />
if not userExists then<br />
Msgbox("User not found")<br />
Exit Sub<br />
End if<br />
<br />
Ace1 = SetAce(scope, 2032127, 3, 0, SetTrustee(scope, serverName, UserName, GetBinarySid(scope, userAccount("sid")))) '<br />
<br />
Dim secDescriptor As Management.ManagementObject<br />
secDescriptor = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_SecurityDescriptor"), Nothing).CreateInstance()<br />
secDescriptor("ControlFlags") = 4<br />
secDescriptor("DACL") = New Management.ManagementObject() {Ace1}<br />
<br />
Dim inParams As Management.ManagementBaseObject<br />
inParams = wmiShare.GetMethodParameters("Create")<br />
inParams("Access") = secDescriptor<br />
inParams("Path") = "C:\new folder"<br />
inParams("Name") = "foldersharename"<br />
inParams("Type") = 0<br />
inParams("MaximumAllowed") = 5<br />
inParams("Description") = "FolderDescriptionHere"<br />
Dim outParams As Management.ManagementBaseObject<br />
<br />
outParams = wmiShare.InvokeMethod("Create", inParams, Nothing)<br />
MsgBox("Successful")<br />
End Sub<br />
<br />
Function GetBinarySid(ByVal scope As ManagementScope, ByVal sid As String)As Byte() <br />
Dim wmiSid As New ManagementObject(scope, New ManagementPath(String.Format("Win32_SID.SID='{0}'", sid)), Nothing)<br />
Return wmiSid("BinaryRepresentation")<br />
End Function<br />
<br />
Function SetTrustee(ByVal scope As Management.ManagementScope, ByVal domain As String, ByVal name As String, ByVal UserSid As Byte()) As Management.ManagementObject<br />
Dim wmiTrustee As Management.ManagementObject<br />
wmiTrustee = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_Trustee"), Nothing).CreateInstance()<br />
wmiTrustee("Domain") = domain<br />
wmiTrustee("Name") = name<br />
wmiTrustee("SID") = UserSid<br />
Return wmiTrustee<br />
End Function<br />
<br />
Function SetAce(ByVal scope As Management.ManagementScope, ByVal accessMask As Integer, ByVal aceFlags As Integer, ByVal aceType As Integer, ByVal wmiTrustee As Management.ManagementObject) As Management.ManagementObject<br />
Dim wmiAce As Management.ManagementObject<br />
wmiAce = New Management.ManagementClass(scope, New Management.ManagementPath("Win32_ACE"), Nothing).CreateInstance()<br />
wmiAce("AccessMask") = accessMask<br />
wmiAce("AceFlags") = aceFlags<br />
wmiAce("AceType") = aceType<br />
wmiAce("Trustee") = wmiTrustee<br />
Return wmiAce<br />
End Function
But steel that message appeared. When I tried to open the folder from Windows Explorer from other machines, message appears again. My user is of Administrator group and has no password. When I share a folder manually from Explorer, all is fine. What is wrong with me?
|
|
|
|
|
battulga wrote: My user is of Administrator group and has no password.
Windows file sharing hates blank passwords. Try setting yourself a password and try it again.
|
|
|
|
|
I have 3 images of different sizes and i want to display all of them in a loop.
how can i resize the images to picture box's size.
|
|
|
|
|
A picture box can be set to do this for you automatically.
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 )
|
|
|
|
|
Picture box will resize itself to the size of picture.
But i want to resize the picture according to the size of picture box.
|
|
|
|
|