none
Visual 2008: ConnecString RRS feed

  • Question

  •  

    If you can help please do so, this has been nagging my brains for a long time.

     

    I'm doing a project for computing in visual 2008, however my college has only provided me with a book that explains the coding in visual 2005, I'm using a connected database and the book tells me to write the following code:

     

    Dim dtDriverIDs As New DataTable()

     

    Dim daDriverIDs As bew OleDbDataAdapter _

    ("Select [Driver ID] from Drivers", ConnectString)

    daDriverIDs.Fill(dtDriverIDs)

    lstDriverIDs.DataSource = dtDriverIDs

    lstDriverIDs.DisplayMemeber = "Driver ID"

     

    The problem is that visual 2008 does not recognize "ConnectString", suggests that daDriverIDs has not been declared and that the syntax before "(" is wrong.

    Any suggestions?

    Saturday, December 1, 2007 3:28 PM

All replies

  • Hello Sudsey,

     

    Is there a line that declares the ConnectString anywhere in your code?

     

    For example, you need to define your connection string like this:

     

     

    Code Block

    Dim ConnectString as String  = "Change this to a valid connection string to your database"

     

    Dim dtDriverIDs As New DataTable()

     

    Dim daDriverIDs As bew OleDbDataAdapter _

    ("Select [Driver ID] from Drivers", ConnectString)

    daDriverIDs.Fill(dtDriverIDs)

    lstDriverIDs.DataSource = dtDriverIDs

    lstDriverIDs.DisplayMemeber = "Driver ID"

     

     

    As far as the syntax error if this is the exact code it should read:

     

    Code Block

    Dim daDriverIDs As NEW OleDbDataAdapter _

    ("Select [Driver ID] from Drivers", ConnectString)

     

     

    Here is a link to the help documentation for working with Data in Visual Studio 2008:

    http://msdn2.microsoft.com/en-us/library/wzabh8c4(VS.90).aspx

     

    Hope that helps...

    Monday, December 10, 2007 11:01 PM