Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 June 24th, 2004, 10:41 AM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default does anyone know wht this code does

hi, can anyone tell me what this section of code does, i got it from a site but the guy hasnt commented it well, by the way i am using a sql data provider, and the code here uses oledb so any ideas how i can do this in sql data provider. many thanks in advance

command.Parameters.Add("username ", Data.OleDb.OleDbType.Variant)

command.Parameters.Add("password", Data.OleDb.OleDbType.Variant)

command.Parameters("username").Value = TextBox1.Text

command.Parameters("password").Value = TextBox2.Text


 
Old June 24th, 2004, 10:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can think of a command as a bridge between your application and a Connection object. A command object can hold a SQL statement, or stored procedure name and has a parameter collection. Parameters can be send off to the database, in case of a Stored Procedure or a parameterized SQL statement.

In this case, two parameters are added to the command's param collection. To make this Sql parmas, replace OleDb with Sql.

Look in the MSDN for loads and loads of more examples of this:

http://msdn.microsoft.com/library/en...classtopic.asp
http://msdn.microsoft.com/library/en...classtopic.asp
http://msdn.microsoft.com/library/en...ClassTopic.asp
Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: The Dark Of The Matinee by Franz Ferdinand (Track 4 from the album: Franz Ferdinand) What's This?
 
Old June 24th, 2004, 10:59 AM
Authorized User
 
Join Date: Jun 2004
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi i have just replaced the oledb bits to sql and i get an error, under "data.sql" it says sql is not a memeber of data.
the code is show below what i have done, many thanks in advance

             command.Parameters.Add("username ", Data.sql.sqlType.Variant)

            command.Parameters.Add("password ", Data.sql.sqlType.Variant)

            command.Parameters("username").Value = TextBox1.Text

            command.Parameters("password").Value = TextBox2.Text

 
Old June 24th, 2004, 11:11 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

If you follow the links I posted, you'll see that the Sql stuff lives in the System.Data.SqlClient namespace.

But IMO, this is never going to work right. Apparently, you're missing a couple of (if not all) important concepts related to .NET. The way I see it, you cannot really learn a new technology by asking questions in a forum. You should do so by reading books and web sites. Of course forums can aid in the learning process, but they cannot teach you everything. If I were you, I'd get a copy of this book:
http://www.wrox.com/books/0764556584.shtml

This books deals with basic VB .NET concepts, including accessing databases etc.

Right now, you try to learn driving on the Monaco circuit, while the parking lot next to your local super market is probably a much better place to start ;)
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Lately by Skunk Anansie (Track 6 from the album: Post Orgasmic Chill) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Urgent:hard disk serial code and vb code ivanlaw Pro VB 6 0 July 25th, 2007 04:05 AM
VB: .Exe file, serial code and activation code ivanlaw Pro VB 6 8 July 6th, 2007 05:44 AM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Writing Client Side Script from Code-Behind code sajid_pk Classic ASP Databases 1 January 18th, 2005 12:53 AM
Wht the procedure is wrong?? 6cet6 SQL Server 2000 4 March 22nd, 2004 11:02 PM





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