Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB 6.0 >>> VB.NET / January 2004

Tip: Looking for answers? Try searching our database.

ADO parameters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve F. - 14 Jan 2004 20:13 GMT
Will this VB6 code run in VB.NET:

With MyCmd
   .CommandType = adCmdText
   .CommandText = "SELECT Pub_Name, City, State WHERE
City LIKE ? AND State = ? "
   .Parameters.Append .CreateParameter("Citywanted",
adVarChar)
   .Parameters.Append .CreateParameter("Statewanted",
AdChar)
End With

or do I have to get rid of the ? placeholders in VB.NET?  
And, if so, what would the above code look like?
Thanks.
Jay B. Harlow [MVP - Outlook] - 15 Jan 2004 03:12 GMT
Steve,
In VB.NET you would use something like:

Imports System.Data.OleDb

       Dim myCmd As OleDbCommand
       With MyCmd
           .CommandType = CommandType.Text
           .CommandText = "SELECT Pub_Name, City, State WHERE City LIKE ?
AND State = ? "
           .Parameters.Add("Citywanted", OleDbType.VarChar)
           .Parameters.Add("Statewanted", OleDbType.Char)
       End With

If you are using the SqlClient, ODBC, Oracle, or other client the code
changes slightly, due to parameters types (OleDbType changes for the type of
client) & possible parameter naming.

The SqlClient does not use the ? placeholders, where as OleDb & ODBC do, I
understand that Oracle does its own thing. Other providers probably do what
ever it is they do (what's "native" for that database).

Check MSDN for the client that you are using for specifics.

Hope this helps
Jay

> Will this VB6 code run in VB.NET:
>
[quoted text clipped - 11 lines]
> And, if so, what would the above code look like?
> Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.