Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Dear All
 

kindly please tell me how i can read all database of sql server in my application of vb.net in combo box
and how i can make manual connection with sql database it ask server and database and user name password always when application stat of vb.net
Posted 1-Feb-13 22:10pm
Comments
Mantu Singh at 2-Feb-13 3:14am
   
read all database of sql server in my application of vb.net in combo box ;-)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Simple Connection and Add THis Query.
 
SELECT name FROM master..sysdatabases
 
Run this Query youe Sql Server And Get ALL Database.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

To read all database names:
Using con As New SqlConnection("Data Source=GRIFFPC\SQLEXPRESS;Integrated Security=True")
	con.Open()
	Using cmd As New SqlCommand("sp_databases", con)
		cmd.CommandType = CommandType.StoredProcedure
		Dim read As SqlDataReader = cmd.ExecuteReader()
		While read.Read()
			Console.WriteLine(DirectCast(read("DATABASE_NAME"), String))
		End While
	End Using
End Using
Your other question is harder to answer - all you have to do is design a form which contains a server name, a user name, and a password field at the minimum, and which returns a connection string, but that really isn't very user-friendly, and probably isn't exactly what you want. Remember that different databases can have different users, and different passwords...
 
Open SSMS and the first screen which appears is probably what you want to duplicate - is any part of that giving you a problem?
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Maciej Los 205
2 Peter Leow 140
3 Suvendu Shekhar Giri 134
4 Abhinav S 126
0 Sergey Alexandrovich Kryukov 9,623
1 OriginalGriff 8,895
2 Peter Leow 5,044
3 Kornfeld Eliyahu Peter 3,333
4 Maciej Los 2,561


Advertise | Privacy | Mobile
Web01 | 2.8.150327.1 | Last Updated 2 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100