Results 1 to 7 of 7

Thread: Introduction to ADO.NET Tutorial, HELP!?

  1. #1

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    Introduction to ADO.NET Tutorial, HELP!?

    Double click the command button. This will open up the code view and add the event handler for the button's click event. To make some of the coding more efficient, add a constant at the top to hold the connection string. This assumes the SQL Server is the local machine and has been set up with the current user as a valid user of the server and uses Windows Authentication. Naturaly you should adjust the ConnectionString to fit your needs.
    what the **** does that mean? Whats a constant? and what does holding the connection string mean?

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Introduction to ADO.NET Tutorial, HELP!?

    Declare your string constant at the top of your class like so.
    VB Code:
    1. Option Explicit On
    2.  
    3. Public Class Form1
    4.  
    5.     Inherits System.Windows.Forms.Form
    6.  
    7.     Public Const strConn As String = "Provider blah blah blah..."
    8.  
    9.         '...
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    Re: Introduction to ADO.NET Tutorial, HELP!?

    First thing we'll do is to add some code to retrieve a list of Products from the database. The steps to do this are straightforward: create a connection, a select command, a data adapter that uses the connection and command, and lastly, fill the DataSet with the data.

    First create the connection:
    code:
    VB Code:
    1. Dim DBConnection As New SqlClient.SqlConnection(MyCONNECTIONSTRING)

    What does MyCONNECTIONSTRING signify, is that something i have to create, like a string of my own code, or what?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Introduction to ADO.NET Tutorial, HELP!?

    Um, in the tutorial MyCONNECTIONSTRING was declared in the previous code box about 2 centimetres above the code you just quoted. It's the constant you were asking about in your previous post. It really sounds to me like you need to get back to basics and improve your grounding in VB.NET before tackling data access. Constants are a pretty basic part of any programming langauge. Variables store a value that varies, while constants store a value that is constant.
    Attached Images Attached Images  
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    Re: Introduction to ADO.NET Tutorial, HELP!?

    Quote Originally Posted by jmcilhinney
    Um, in the tutorial MyCONNECTIONSTRING was declared in the previous code box about 2 centimetres above the code you just quoted. It's the constant you were asking about in your previous post. It really sounds to me like you need to get back to basics and improve your grounding in VB.NET before tackling data access. Constants are a pretty basic part of any programming langauge. Variables store a value that varies, while constants store a value that is constant.

    I have roughly been using VB for about 1 1/2 weeks.
    I dont know jack sh*t, im just trying to pick it up as i go, by following tutorials, listening to what people say, and gettin people to explain in every detail, what the things do, and how they do it.

    Click on my nickname, and read my profile. That will give you a better idea of what im up against.

    You guys are helping heaps, but i just need to cram as much information in my brain as i can.

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Introduction to ADO.NET Tutorial, HELP!?

    There's not much point cramming information in one side if more is falling out the other and a good part of the rest is spilling out befroe it gets in. The fact that you missed the declaration of MyCONNECTIONSTRING proves that you're not absorbing what you're reading, so I'd suggest that you slow down and concentrate on quality rather than quantity. If you don't know what a connection string is then the code you posted in your previous thread was obviously not your own, so you're asking how to delete data before you even really know how to retrieve it. Have you heard an expression about walking and running?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Member leonreeet's Avatar
    Join Date
    Jul 2006
    Location
    Perth, Western Australia
    Posts
    32

    Re: Introduction to ADO.NET Tutorial, HELP!?

    Quote Originally Posted by jmcilhinney
    There's not much point cramming information in one side if more is falling out the other and a good part of the rest is spilling out befroe it gets in. The fact that you missed the declaration of MyCONNECTIONSTRING proves that you're not absorbing what you're reading, so I'd suggest that you slow down and concentrate on quality rather than quantity. If you don't know what a connection string is then the code you posted in your previous thread was obviously not your own, so you're asking how to delete data before you even really know how to retrieve it. Have you heard an expression about walking and running?
    yeh i get ya, no need to point ou what i already know, i asked about Deleting a row in an ACCESS database that i was using, but you directed me along to something more difficult.

    i obviously dont know how to write code from scratch, cos i dont have an undertanding of everything atm. But i have learnt more trying to put together a mock program, with a database, than i have sitting and watching video tutorials, or just reading stuff.

    Hands on, trying to figure stuff out, is how im remebering things and learning along the way, i have no one to ask questions to, apart from people on forums and people on forums treat everyone like they are already experts.

    So i just have to kind of make due.

    believe me the help you are giving me is definatly worth while, i just need some guidance.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width