Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write parameter method in VB.NET?

Status
Not open for further replies.

joggi

Programmer
Nov 8, 2006
44
YU
I am new in VB.NET. I need to write connection to database, but the name of database, server, username and password are in INI file. How to write this?
Second, I need to write one parameter method "Select *from Table....." where Table is parameter, so I can use this method for all my tables.
Can anybody help me with this?
Thank you in advance
 
First, INI files are a thing of the past. Since you're using .NET now, you should use the app.config file to store such information. Here's a MS support article on using the app.config...


Second, you can create a public method to select from any table...

Code:
Public Sub SelectAllFromTable (TableName as String)

   Dim strSQL as String

   strSQL = "SELECT * FROM " & TableName

   ...
End Sub

And for Database interaction, look into some tutorials on ADO.NET. Here's a good starting point for you...


Good Luck!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top