Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 by Thearon Willis, Bryan Newsome; ISBN: 9780764574016
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2007, 06:49 AM
Registered User
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Techniques for connecting to SQL Server 2k5 db's

Hi All

I am an absolute newbie to connection to SQL-Server databases in VB 2k5 so I really hope you can clearify a couple of issues for me.

After studying both the "Beginning Visual Basic 2005" and "Beginning Visual Basic 2005 Databases" books (which I enjoyed a great deal) I am fairly confused in regards to how to connect to a SQL Server database from a Visual Basic Windows Application...

The way I understand the mentioned textbooks there serveral ways (i.e. alternatives) to build a connections???

Now my quistion is, what way is the easiest, most simple way to do this?

I am not very keen on using the DataSource that produces xml-files, as I do not feel very safe in using xml.

I really hope you can ease my confusion and your reply will be hugely appriciated.



Kind regards
Tina Nielsen, Denmark
 
Old August 23rd, 2007, 12:27 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Hello Tina,
   I have found that using the Microsoft.ApplicationBlocks.Data.dll simplifies database work. (This dll is something that does not come with .NET, you need to download the source code from MS, compile it yourself, then add a reference to the dll in your project)

What you wind up with are calls that look like this (The VB syntax is similar):

DataTable dt = SqlHelper.ExecuteDataset( <connection string>, CommandType.StoredProcedure, "usp_foo").Tables[0];

SqlHelper is a public class inside of the ApplicationBlock that also exposes these methods and functions: ExecuteScalar, ExecuteNonQuery, ExecuteReader, and ExecuteXMLReader

Of course you can create your own data layer where you define your data adapters, connections, data readers etc.

hth.


================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Professional Search Engine Optimization with ASP.NET

Professional IIS 7 and ASP.NET Integrated Programming

================================================== =========
 
Old August 25th, 2007, 05:18 AM
Thearon's Avatar
Wrox Author
 
Join Date: Dec 2003
Posts: 396
Thanks: 0
Thanked 8 Times in 8 Posts
Default

Tina,

You can code your connection strings in the app.config file for Windows applications or the web.config file for Web applications.

Of course you do not want to put these connection strings in plain text so I would suggest that you encrypt them and then place the encrypted values in your app.config or web.config file and then decrypt them in your application.

Chapter 10 in Beginning Visual Basic 2005 Databases covers encrypting and decrypting values.

Thearon





Similar Threads
Thread Thread Starter Forum Replies Last Post
Inconsistent connection to SQL Server 2K5 kscase_apc SQL Server 2005 3 May 30th, 2007 02:34 PM
Connecting to SQL 2K5 - examples kscase VB Databases Basics 1 January 17th, 2007 05:48 PM
Connecting WroxUnited DB's in SQL Server 2000 TritonOps ASP.NET 2.0 Basics 8 September 7th, 2006 11:29 PM
URGENT:Connecting SQL server through Proxy server abhowal SQL Server 2000 3 November 30th, 2005 04:22 AM
2 db's on one server dungey MySQL 2 May 12th, 2004 05:49 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.