Manual database connection in vs2005

Hi

I was trying to make a database connection in a windows application using vb.net in vs2005

The following code did'nt work------------------!!!!!

1. Inherits System.Data.OleDb

Error displayed: Statement is not valid in a namespace.

My Comments: I wanted to include the above class to use the components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.

But what is wrong with the above code, incase I want to make a connection with MS access database manually?

2. Whenever I try to create a data adapter by writing the following code -

oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()

On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----

OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())

What is the mistake that I am making?

Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.


In all, I am finding it difficult to make a database connection in vs2005, manually.

However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.


Regards,
Ruchika



Comments

  • : Hi
    :
    : I was trying to make a database connection in a windows application using vb.net in vs2005
    :
    : The following code did'nt work------------------!!!!!
    :
    : 1. Inherits System.Data.OleDb
    :
    : Error displayed: Statement is not valid in a namespace.
    :
    : My Comments: I wanted to include the above class to use the

    [red]
    Place this at the top of the code file instead:
    [/red]

    [code]
    Imports System.Data.OleDb
    [/code]

    components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.
    :
    : But what is wrong with the above code, incase I want to make a connection with MS access database manually?
    :
    : 2. Whenever I try to create a data adapter by writing the following code -
    :
    : oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()
    :
    : On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----
    :
    : OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())

    [red]
    Your trying to write VB like C#, try this instead:
    [/red]

    [code]
    Dim myadapt As New oledb.oledbDataAdapter
    [/code]

    :
    : What is the mistake that I am making?
    :
    : Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.
    :
    :
    : In all, I am finding it difficult to make a database connection in vs2005, manually.
    :
    : However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.
    :
    :
    : Regards,
    : Ruchika
    :
    :
    :
    :

  • Hey, thanks a lot.....it works now...

    I was making a stupid mistake...Thanks again

    Regards,
    Ruchika


    : : Hi
    : :
    : : I was trying to make a database connection in a windows application using vb.net in vs2005
    : :
    : : The following code did'nt work------------------!!!!!
    : :
    : : 1. Inherits System.Data.OleDb
    : :
    : : Error displayed: Statement is not valid in a namespace.
    : :
    : : My Comments: I wanted to include the above class to use the
    :
    : [red]
    : Place this at the top of the code file instead:
    : [/red]
    :
    : [code]
    : Imports System.Data.OleDb
    : [/code]
    :
    : components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.
    : :
    : : But what is wrong with the above code, incase I want to make a connection with MS access database manually?
    : :
    : : 2. Whenever I try to create a data adapter by writing the following code -
    : :
    : : oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()
    : :
    : : On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----
    : :
    : : OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())
    :
    : [red]
    : Your trying to write VB like C#, try this instead:
    : [/red]
    :
    : [code]
    : Dim myadapt As New oledb.oledbDataAdapter
    : [/code]
    :
    : :
    : : What is the mistake that I am making?
    : :
    : : Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.
    : :
    : :
    : : In all, I am finding it difficult to make a database connection in vs2005, manually.
    : :
    : : However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.
    : :
    : :
    : : Regards,
    : : Ruchika
    : :
    : :
    : :
    : :
    :
    :



  • No problem ... it happens to the best of us all

    : Hey, thanks a lot.....it works now...
    :
    : I was making a stupid mistake...Thanks again
    :
    : Regards,
    : Ruchika
    :
    :
    : : : Hi
    : : :
    : : : I was trying to make a database connection in a windows application using vb.net in vs2005
    : : :
    : : : The following code did'nt work------------------!!!!!
    : : :
    : : : 1. Inherits System.Data.OleDb
    : : :
    : : : Error displayed: Statement is not valid in a namespace.
    : : :
    : : : My Comments: I wanted to include the above class to use the
    : :
    : : [red]
    : : Place this at the top of the code file instead:
    : : [/red]
    : :
    : : [code]
    : : Imports System.Data.OleDb
    : : [/code]
    : :
    : : components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.
    : : :
    : : : But what is wrong with the above code, incase I want to make a connection with MS access database manually?
    : : :
    : : : 2. Whenever I try to create a data adapter by writing the following code -
    : : :
    : : : oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()
    : : :
    : : : On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----
    : : :
    : : : OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())
    : :
    : : [red]
    : : Your trying to write VB like C#, try this instead:
    : : [/red]
    : :
    : : [code]
    : : Dim myadapt As New oledb.oledbDataAdapter
    : : [/code]
    : :
    : : :
    : : : What is the mistake that I am making?
    : : :
    : : : Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.
    : : :
    : : :
    : : : In all, I am finding it difficult to make a database connection in vs2005, manually.
    : : :
    : : : However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.
    : : :
    : : :
    : : : Regards,
    : : : Ruchika
    : : :
    : : :
    : : :
    : : :
    : :
    : :
    :
    :
    :
    :

  • : Hi
    :
    : I was trying to make a database connection in a windows application using vb.net in vs2005
    :
    : The following code did'nt work------------------!!!!!
    :
    : 1. Inherits System.Data.OleDb
    :
    : Error displayed: Statement is not valid in a namespace.
    :
    : My Comments: I wanted to include the above class to use the components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.
    :
    : But what is wrong with the above code, incase I want to make a connection with MS access database manually?
    :
    : 2. Whenever I try to create a data adapter by writing the following code -
    :
    : oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()
    :
    : On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----
    :
    : OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())
    :
    : What is the mistake that I am making?
    :
    : Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.
    :
    :
    : In all, I am finding it difficult to make a database connection in vs2005, manually.
    :
    : However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.
    :
    :
    : Regards,
    : Ruchika
    :
    :
    :
    :

  • : : Hi
    : : change Inherits System.Data.OleDb
    to
    Imports System.Data.OleDb


    : : I was trying to make a database connection in a windows application using vb.net in vs2005
    : :
    : : The following code did'nt work------------------!!!!!
    : :
    : : 1. Inherits System.Data.OleDb
    : :
    : : Error displayed: Statement is not valid in a namespace.
    : :
    : : My Comments: I wanted to include the above class to use the components of OleDb data provider. But since it did'nt work, I made a connection via the server explorer window...and anyhow the connection was successfully made.
    : :
    : : But what is wrong with the above code, incase I want to make a connection with MS access database manually?
    : :
    : : 2. Whenever I try to create a data adapter by writing the following code -
    : :
    : : oledb.oledbDataAdapter myadapt = new oledb.oledbDataAdapter()
    : :
    : : On pressing "Enter" an unusual thing happens...the above written code gets converted into something like this-----
    : :
    : : OleDb.OleDbDataAdapter(myadapt = New OleDb.OleDbDataAdapter())
    : :
    : : What is the mistake that I am making?
    : :
    : : Also I don't know what arguments are to be passed to the dataAdapter object(myadapt) that I am trying to create as the name of the connection created is not known to me.
    : :
    : :
    : : In all, I am finding it difficult to make a database connection in vs2005, manually.
    : :
    : : However, using a wizard for the same is not creating any problems but please let me know if I am missing out any code.
    : :
    : :
    : : Regards,
    : : Ruchika
    : :
    : :
    : :
    : :
    :
    :

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories