How to put query in database?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Wim

    How to put query in database?

    Hi,

    I would like to make and put a query in my database by VB.NET code.

    Is this possible?

    Thanks for your help,

    wim


  • Dominique Vandensteen

    #2
    Re: How to put query in database?

    do you mean create a stored procedure?


    Dim conn As New SqlConnection(m yConnectionStri ng)
    conn.Open()
    Dim cmd As SqlCommand = conn.CreateComm and()
    cmd.CommandText = "CREATE PROCEDURE myNewStoredProc edure AS select * from
    mytable"
    cmd.ExecuteNonQ uery()
    conn.Close()


    Hope this helps

    Dominique



    "Wim" <wim.verlinden@ pandora.be> wrote in message
    news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...[color=blue]
    > Hi,
    >
    > I would like to make and put a query in my database by VB.NET code.
    >
    > Is this possible?
    >
    > Thanks for your help,
    >
    > wim
    >
    >[/color]


    Comment

    • Cor

      #3
      Re: How to put query in database?

      Hi Wim,

      Something as this
      \\\
      Dim Conn As New SqlConnection(c onnString)
      Dim myCommand As New SqlCommand("sel ect count(*) from tblMessages", Conn)
      myCommand.Conne ction.Open()
      Dim count As Integer = CInt(myCommand. ExecuteScalar() )
      Conn.Close()
      ///

      I hope this helps?

      Cor


      Comment

      • Wim

        #4
        Re: How to put query in database?

        Hi Cor and Dominique,

        I just need to make a new query and save this in an access database....

        Is your code doing this?

        Regards,

        wim


        "Wim" <wim.verlinden@ pandora.be> schreef in bericht
        news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...[color=blue]
        > Hi,
        >
        > I would like to make and put a query in my database by VB.NET code.
        >
        > Is this possible?
        >
        > Thanks for your help,
        >
        > wim
        >
        >[/color]


        Comment

        • Wim

          #5
          Re: How to put query in database?

          the access database is located at
          "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"

          "Wim" <wim.verlinden@ pandora.be> schreef in bericht
          news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...[color=blue]
          > Hi,
          >
          > I would like to make and put a query in my database by VB.NET code.
          >
          > Is this possible?
          >
          > Thanks for your help,
          >
          > wim
          >
          >[/color]


          Comment

          • Dominique Vandensteen

            #6
            Re: How to put query in database?

            do you want to put your query as data in a table?
            if so see code
            if put it in access as a stored procedure then no can do...



            Imports System.Data.Ole Db


            dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
            Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
            conn.Open()
            Dim cmd As SqlCommand = conn.CreateComm and()
            cmd.CommandText = "insert into mytable (columnname) values ('the query...')"
            cmd.ExecuteNonQ uery()
            conn.Close()


            Dominique


            "Wim" <wim.verlinden@ pandora.be> wrote in message
            news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...[color=blue]
            > the access database is located at
            > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
            >
            > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
            > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...[color=green]
            > > Hi,
            > >
            > > I would like to make and put a query in my database by VB.NET code.
            > >
            > > Is this possible?
            > >
            > > Thanks for your help,
            > >
            > > wim
            > >
            > >[/color]
            >
            >[/color]


            Comment

            • Wim

              #7
              Re: How to put query in database?

              No I don't want to put data in the table...

              only put a new query in the access database and use it later..

              So you think this is impossible??

              Regards

              wim



              ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
              bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...[color=blue]
              > do you want to put your query as data in a table?
              > if so see code
              > if put it in access as a stored procedure then no can do...
              >
              >
              >
              > Imports System.Data.Ole Db
              >
              >
              > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
              > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
              > conn.Open()
              > Dim cmd As SqlCommand = conn.CreateComm and()
              > cmd.CommandText = "insert into mytable (columnname) values ('the[/color]
              query...')"[color=blue]
              > cmd.ExecuteNonQ uery()
              > conn.Close()
              >
              >
              > Dominique
              >
              >
              > "Wim" <wim.verlinden@ pandora.be> wrote in message
              > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...[color=green]
              > > the access database is located at
              > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
              > >
              > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
              > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...[color=darkred]
              > > > Hi,
              > > >
              > > > I would like to make and put a query in my database by VB.NET code.
              > > >
              > > > Is this possible?
              > > >
              > > > Thanks for your help,
              > > >
              > > > wim
              > > >
              > > >[/color]
              > >
              > >[/color]
              >
              >[/color]


              Comment

              • Dominique Vandensteen

                #8
                Re: How to put query in database?

                you can do something alike stored procedures with access (queries)
                but I don't know if you can create them from vb.net code

                to call them:

                dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                conn.Open()
                Dim cmd As OleDbCommand = conn.CreateComm and()
                cmd.CommandType = CommandType.Sto redProcedure
                cmd.CommandText = "myquery"


                Dominique


                "Wim" <wim.verlinden@ pandora.be> wrote in message
                news:IeaPb.2099 3$qh2.3942440@p hobos.telenet-ops.be...[color=blue]
                > No I don't want to put data in the table...
                >
                > only put a new query in the access database and use it later..
                >
                > So you think this is impossible??
                >
                > Regards
                >
                > wim
                >
                >
                >
                > ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
                > bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...[color=green]
                > > do you want to put your query as data in a table?
                > > if so see code
                > > if put it in access as a stored procedure then no can do...
                > >
                > >
                > >
                > > Imports System.Data.Ole Db
                > >
                > >
                > > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                > > conn.Open()
                > > Dim cmd As SqlCommand = conn.CreateComm and()
                > > cmd.CommandText = "insert into mytable (columnname) values ('the[/color]
                > query...')"[color=green]
                > > cmd.ExecuteNonQ uery()
                > > conn.Close()
                > >
                > >
                > > Dominique
                > >
                > >
                > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                > > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...[color=darkred]
                > > > the access database is located at
                > > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
                > > >
                > > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                > > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...
                > > > > Hi,
                > > > >
                > > > > I would like to make and put a query in my database by VB.NET code.
                > > > >
                > > > > Is this possible?
                > > > >
                > > > > Thanks for your help,
                > > > >
                > > > > wim
                > > > >
                > > > >
                > > >
                > > >[/color]
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Wim

                  #9
                  Re: How to put query in database?

                  ok ,thanks a lot

                  wim
                  "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
                  bericht news:udliFy13DH A.560@TK2MSFTNG P11.phx.gbl...[color=blue]
                  > you can do something alike stored procedures with access (queries)
                  > but I don't know if you can create them from vb.net code
                  >
                  > to call them:
                  >
                  > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                  > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                  > conn.Open()
                  > Dim cmd As OleDbCommand = conn.CreateComm and()
                  > cmd.CommandType = CommandType.Sto redProcedure
                  > cmd.CommandText = "myquery"
                  >
                  >
                  > Dominique
                  >
                  >
                  > "Wim" <wim.verlinden@ pandora.be> wrote in message
                  > news:IeaPb.2099 3$qh2.3942440@p hobos.telenet-ops.be...[color=green]
                  > > No I don't want to put data in the table...
                  > >
                  > > only put a new query in the access database and use it later..
                  > >
                  > > So you think this is impossible??
                  > >
                  > > Regards
                  > >
                  > > wim
                  > >
                  > >
                  > >
                  > > ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
                  > > bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...[color=darkred]
                  > > > do you want to put your query as data in a table?
                  > > > if so see code
                  > > > if put it in access as a stored procedure then no can do...
                  > > >
                  > > >
                  > > >
                  > > > Imports System.Data.Ole Db
                  > > >
                  > > >
                  > > > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                  > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                  > > > conn.Open()
                  > > > Dim cmd As SqlCommand = conn.CreateComm and()
                  > > > cmd.CommandText = "insert into mytable (columnname) values ('the[/color]
                  > > query...')"[color=darkred]
                  > > > cmd.ExecuteNonQ uery()
                  > > > conn.Close()
                  > > >
                  > > >
                  > > > Dominique
                  > > >
                  > > >
                  > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                  > > > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...
                  > > > > the access database is located at
                  > > > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
                  > > > >
                  > > > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                  > > > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...
                  > > > > > Hi,
                  > > > > >
                  > > > > > I would like to make and put a query in my database by VB.NET[/color][/color][/color]
                  code.[color=blue][color=green][color=darkred]
                  > > > > >
                  > > > > > Is this possible?
                  > > > > >
                  > > > > > Thanks for your help,
                  > > > > >
                  > > > > > wim
                  > > > > >
                  > > > > >
                  > > > >
                  > > > >
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  • Wim

                    #10
                    Re: How to put query in database?

                    Hi Dominique,

                    I get error "An unhandled exception of type
                    'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll " at
                    conn.open()

                    what can i do?

                    Regards,

                    wim

                    Imports System.Data.Ole Db

                    Public Class Form1

                    Inherits System.Windows. Forms.Form

                    #Region " Windows Form Designer generated code "

                    Public Sub New()

                    MyBase.New()

                    'This call is required by the Windows Form Designer.

                    InitializeCompo nent()

                    'Add any initialization after the InitializeCompo nent() call

                    End Sub

                    'Form overrides dispose to clean up the component list.

                    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

                    If disposing Then

                    If Not (components Is Nothing) Then

                    components.Disp ose()

                    End If

                    End If

                    MyBase.Dispose( disposing)

                    End Sub

                    'Required by the Windows Form Designer

                    Private components As System.Componen tModel.IContain er

                    'NOTE: The following procedure is required by the Windows Form Designer

                    'It can be modified using the Windows Form Designer.

                    'Do not modify it using the code editor.

                    <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()

                    '

                    'Form1

                    '

                    Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)

                    Me.ClientSize = New System.Drawing. Size(292, 266)

                    Me.Name = "Form1"

                    Me.Text = "Form1"

                    End Sub

                    #End Region

                    Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
                    System.EventArg s) Handles MyBase.Load

                    Dim conn As New
                    OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;DataSource =C:\backup
                    Compaq MV500\TAGS\Acce ss\2003.mdb")

                    conn.Open()

                    Dim cmd As OleDbCommand = conn.CreateComm and()

                    cmd.CommandType = CommandType.Sto redProcedure

                    cmd.CommandText = "select * from import"

                    End Sub

                    End Class



                    "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                    news:oOaPb.2103 8$zw2.4010073@p hobos.telenet-ops.be...[color=blue]
                    > ok ,thanks a lot
                    >
                    > wim
                    > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
                    > bericht news:udliFy13DH A.560@TK2MSFTNG P11.phx.gbl...[color=green]
                    > > you can do something alike stored procedures with access (queries)
                    > > but I don't know if you can create them from vb.net code
                    > >
                    > > to call them:
                    > >
                    > > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                    > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                    > > conn.Open()
                    > > Dim cmd As OleDbCommand = conn.CreateComm and()
                    > > cmd.CommandType = CommandType.Sto redProcedure
                    > > cmd.CommandText = "myquery"
                    > >
                    > >
                    > > Dominique
                    > >
                    > >
                    > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                    > > news:IeaPb.2099 3$qh2.3942440@p hobos.telenet-ops.be...[color=darkred]
                    > > > No I don't want to put data in the table...
                    > > >
                    > > > only put a new query in the access database and use it later..
                    > > >
                    > > > So you think this is impossible??
                    > > >
                    > > > Regards
                    > > >
                    > > > wim
                    > > >
                    > > >
                    > > >
                    > > > ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef[/color][/color][/color]
                    in[color=blue][color=green][color=darkred]
                    > > > bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...
                    > > > > do you want to put your query as data in a table?
                    > > > > if so see code
                    > > > > if put it in access as a stored procedure then no can do...
                    > > > >
                    > > > >
                    > > > >
                    > > > > Imports System.Data.Ole Db
                    > > > >
                    > > > >
                    > > > > dim conn as New[/color][/color][/color]
                    OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data[color=blue][color=green][color=darkred]
                    > > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                    > > > > conn.Open()
                    > > > > Dim cmd As SqlCommand = conn.CreateComm and()
                    > > > > cmd.CommandText = "insert into mytable (columnname) values ('the
                    > > > query...')"
                    > > > > cmd.ExecuteNonQ uery()
                    > > > > conn.Close()
                    > > > >
                    > > > >
                    > > > > Dominique
                    > > > >
                    > > > >
                    > > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                    > > > > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...
                    > > > > > the access database is located at
                    > > > > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
                    > > > > >
                    > > > > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                    > > > > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...
                    > > > > > > Hi,
                    > > > > > >
                    > > > > > > I would like to make and put a query in my database by VB.NET[/color][/color]
                    > code.[color=green][color=darkred]
                    > > > > > >
                    > > > > > > Is this possible?
                    > > > > > >
                    > > > > > > Thanks for your help,
                    > > > > > >
                    > > > > > > wim
                    > > > > > >
                    > > > > > >
                    > > > > >
                    > > > > >
                    > > > >
                    > > > >
                    > > >
                    > > >[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • Dominique Vandensteen

                      #11
                      Re: How to put query in database?

                      9 out of 10 your db is in use :-)

                      do a try/catch and check the exception message and stacktrace for more
                      info...


                      hope this helps

                      dominique

                      "Wim" <wim.verlinden@ pandora.be> wrote in message
                      news:DPhPb.2187 0$Y53.4055135@p hobos.telenet-ops.be...[color=blue]
                      > Hi Dominique,
                      >
                      > I get error "An unhandled exception of type
                      > 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll " at
                      > conn.open()
                      >
                      > what can i do?
                      >
                      > Regards,
                      >
                      > wim
                      >
                      > Imports System.Data.Ole Db
                      >
                      > Public Class Form1
                      >
                      > Inherits System.Windows. Forms.Form
                      >
                      > #Region " Windows Form Designer generated code "
                      >
                      > Public Sub New()
                      >
                      > MyBase.New()
                      >
                      > 'This call is required by the Windows Form Designer.
                      >
                      > InitializeCompo nent()
                      >
                      > 'Add any initialization after the InitializeCompo nent() call
                      >
                      > End Sub
                      >
                      > 'Form overrides dispose to clean up the component list.
                      >
                      > Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                      >
                      > If disposing Then
                      >
                      > If Not (components Is Nothing) Then
                      >
                      > components.Disp ose()
                      >
                      > End If
                      >
                      > End If
                      >
                      > MyBase.Dispose( disposing)
                      >
                      > End Sub
                      >
                      > 'Required by the Windows Form Designer
                      >
                      > Private components As System.Componen tModel.IContain er
                      >
                      > 'NOTE: The following procedure is required by the Windows Form Designer
                      >
                      > 'It can be modified using the Windows Form Designer.
                      >
                      > 'Do not modify it using the code editor.
                      >
                      > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub[/color]
                      InitializeCompo nent()[color=blue]
                      >
                      > '
                      >
                      > 'Form1
                      >
                      > '
                      >
                      > Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
                      >
                      > Me.ClientSize = New System.Drawing. Size(292, 266)
                      >
                      > Me.Name = "Form1"
                      >
                      > Me.Text = "Form1"
                      >
                      > End Sub
                      >
                      > #End Region
                      >
                      > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
                      > System.EventArg s) Handles MyBase.Load
                      >
                      > Dim conn As New
                      > OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;DataSource =C:\backup
                      > Compaq MV500\TAGS\Acce ss\2003.mdb")
                      >
                      > conn.Open()
                      >
                      > Dim cmd As OleDbCommand = conn.CreateComm and()
                      >
                      > cmd.CommandType = CommandType.Sto redProcedure
                      >
                      > cmd.CommandText = "select * from import"
                      >
                      > End Sub
                      >
                      > End Class
                      >
                      >
                      >
                      > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                      > news:oOaPb.2103 8$zw2.4010073@p hobos.telenet-ops.be...[color=green]
                      > > ok ,thanks a lot
                      > >
                      > > wim
                      > > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef[/color][/color]
                      in[color=blue][color=green]
                      > > bericht news:udliFy13DH A.560@TK2MSFTNG P11.phx.gbl...[color=darkred]
                      > > > you can do something alike stored procedures with access (queries)
                      > > > but I don't know if you can create them from vb.net code
                      > > >
                      > > > to call them:
                      > > >
                      > > > dim conn as New OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data
                      > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                      > > > conn.Open()
                      > > > Dim cmd As OleDbCommand = conn.CreateComm and()
                      > > > cmd.CommandType = CommandType.Sto redProcedure
                      > > > cmd.CommandText = "myquery"
                      > > >
                      > > >
                      > > > Dominique
                      > > >
                      > > >
                      > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                      > > > news:IeaPb.2099 3$qh2.3942440@p hobos.telenet-ops.be...
                      > > > > No I don't want to put data in the table...
                      > > > >
                      > > > > only put a new query in the access database and use it later..
                      > > > >
                      > > > > So you think this is impossible??
                      > > > >
                      > > > > Regards
                      > > > >
                      > > > > wim
                      > > > >
                      > > > >
                      > > > >
                      > > > > ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef[/color][/color]
                      > in[color=green][color=darkred]
                      > > > > bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...
                      > > > > > do you want to put your query as data in a table?
                      > > > > > if so see code
                      > > > > > if put it in access as a stored procedure then no can do...
                      > > > > >
                      > > > > >
                      > > > > >
                      > > > > > Imports System.Data.Ole Db
                      > > > > >
                      > > > > >
                      > > > > > dim conn as New[/color][/color]
                      > OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data[color=green][color=darkred]
                      > > > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                      > > > > > conn.Open()
                      > > > > > Dim cmd As SqlCommand = conn.CreateComm and()
                      > > > > > cmd.CommandText = "insert into mytable (columnname) values ('the
                      > > > > query...')"
                      > > > > > cmd.ExecuteNonQ uery()
                      > > > > > conn.Close()
                      > > > > >
                      > > > > >
                      > > > > > Dominique
                      > > > > >
                      > > > > >
                      > > > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                      > > > > > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...
                      > > > > > > the access database is located at
                      > > > > > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
                      > > > > > >
                      > > > > > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                      > > > > > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...
                      > > > > > > > Hi,
                      > > > > > > >
                      > > > > > > > I would like to make and put a query in my database by VB.NET[/color]
                      > > code.[color=darkred]
                      > > > > > > >
                      > > > > > > > Is this possible?
                      > > > > > > >
                      > > > > > > > Thanks for your help,
                      > > > > > > >
                      > > > > > > > wim
                      > > > > > > >
                      > > > > > > >
                      > > > > > >
                      > > > > > >
                      > > > > >
                      > > > > >
                      > > > >
                      > > > >
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • Wim

                        #12
                        Re: How to put query in database?


                        Hi Dominique,

                        I tried and got this errors :

                        Kan het installeerbare ISAM-bestand niet vinden.
                        at System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr)
                        at System.Data.Ole Db.OleDbConnect ion.InitializeP rovider()
                        at System.Data.Ole Db.OleDbConnect ion.Open()
                        at make_query_20_j an_2004.Form1.F orm1_Load(Objec t sender, EventArgs e) in
                        C:\Documents and Settings\Eigena ar\Mijn documenten\Visu al Studio
                        Projects\make query 20 jan 2004\Form1.vb:l ine 63

                        Any idea?

                        regards,

                        Wim



                        Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
                        System.EventArg s) Handles MyBase.Load

                        Dim conn As New
                        OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;DataSource =C:\backup
                        Compaq MV500\TAGS\Acce ss\2003.mdb")

                        Try

                        conn.Open()

                        Catch ex As Exception

                        TextBox1.Text = (ex.Message)

                        TextBox1.Text = TextBox1.Text & (ex.StackTrace)

                        'conn.Close()

                        End Try

                        Dim cmd As OleDbCommand = conn.CreateComm and()

                        cmd.CommandType = CommandType.Sto redProcedure

                        cmd.CommandText = "select * from import"

                        End Sub



                        "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef in
                        bericht news:OIUb5V63DH A.1636@TK2MSFTN GP12.phx.gbl...[color=blue]
                        > 9 out of 10 your db is in use :-)
                        >
                        > do a try/catch and check the exception message and stacktrace for more
                        > info...
                        >
                        >
                        > hope this helps
                        >
                        > dominique
                        >
                        > "Wim" <wim.verlinden@ pandora.be> wrote in message
                        > news:DPhPb.2187 0$Y53.4055135@p hobos.telenet-ops.be...[color=green]
                        > > Hi Dominique,
                        > >
                        > > I get error "An unhandled exception of type
                        > > 'System.Data.Ol eDb.OleDbExcept ion' occurred in system.data.dll " at
                        > > conn.open()
                        > >
                        > > what can i do?
                        > >
                        > > Regards,
                        > >
                        > > wim
                        > >
                        > > Imports System.Data.Ole Db
                        > >
                        > > Public Class Form1
                        > >
                        > > Inherits System.Windows. Forms.Form
                        > >
                        > > #Region " Windows Form Designer generated code "
                        > >
                        > > Public Sub New()
                        > >
                        > > MyBase.New()
                        > >
                        > > 'This call is required by the Windows Form Designer.
                        > >
                        > > InitializeCompo nent()
                        > >
                        > > 'Add any initialization after the InitializeCompo nent() call
                        > >
                        > > End Sub
                        > >
                        > > 'Form overrides dispose to clean up the component list.
                        > >
                        > > Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
                        > >
                        > > If disposing Then
                        > >
                        > > If Not (components Is Nothing) Then
                        > >
                        > > components.Disp ose()
                        > >
                        > > End If
                        > >
                        > > End If
                        > >
                        > > MyBase.Dispose( disposing)
                        > >
                        > > End Sub
                        > >
                        > > 'Required by the Windows Form Designer
                        > >
                        > > Private components As System.Componen tModel.IContain er
                        > >
                        > > 'NOTE: The following procedure is required by the Windows Form Designer
                        > >
                        > > 'It can be modified using the Windows Form Designer.
                        > >
                        > > 'Do not modify it using the code editor.
                        > >
                        > > <System.Diagnos tics.DebuggerSt epThrough()> Private Sub[/color]
                        > InitializeCompo nent()[color=green]
                        > >
                        > > '
                        > >
                        > > 'Form1
                        > >
                        > > '
                        > >
                        > > Me.AutoScaleBas eSize = New System.Drawing. Size(5, 13)
                        > >
                        > > Me.ClientSize = New System.Drawing. Size(292, 266)
                        > >
                        > > Me.Name = "Form1"
                        > >
                        > > Me.Text = "Form1"
                        > >
                        > > End Sub
                        > >
                        > > #End Region
                        > >
                        > > Private Sub Form1_Load(ByVa l sender As System.Object, ByVal e As
                        > > System.EventArg s) Handles MyBase.Load
                        > >
                        > > Dim conn As New
                        > > OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;DataSource =C:\backup
                        > > Compaq MV500\TAGS\Acce ss\2003.mdb")
                        > >
                        > > conn.Open()
                        > >
                        > > Dim cmd As OleDbCommand = conn.CreateComm and()
                        > >
                        > > cmd.CommandType = CommandType.Sto redProcedure
                        > >
                        > > cmd.CommandText = "select * from import"
                        > >
                        > > End Sub
                        > >
                        > > End Class
                        > >
                        > >
                        > >
                        > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                        > > news:oOaPb.2103 8$zw2.4010073@p hobos.telenet-ops.be...[color=darkred]
                        > > > ok ,thanks a lot
                        > > >
                        > > > wim
                        > > > "Dominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com> schreef[/color][/color]
                        > in[color=green][color=darkred]
                        > > > bericht news:udliFy13DH A.560@TK2MSFTNG P11.phx.gbl...
                        > > > > you can do something alike stored procedures with access (queries)
                        > > > > but I don't know if you can create them from vb.net code
                        > > > >
                        > > > > to call them:
                        > > > >
                        > > > > dim conn as New[/color][/color][/color]
                        OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data[color=blue][color=green][color=darkred]
                        > > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                        > > > > conn.Open()
                        > > > > Dim cmd As OleDbCommand = conn.CreateComm and()
                        > > > > cmd.CommandType = CommandType.Sto redProcedure
                        > > > > cmd.CommandText = "myquery"
                        > > > >
                        > > > >
                        > > > > Dominique
                        > > > >
                        > > > >
                        > > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                        > > > > news:IeaPb.2099 3$qh2.3942440@p hobos.telenet-ops.be...
                        > > > > > No I don't want to put data in the table...
                        > > > > >
                        > > > > > only put a new query in the access database and use it later..
                        > > > > >
                        > > > > > So you think this is impossible??
                        > > > > >
                        > > > > > Regards
                        > > > > >
                        > > > > > wim
                        > > > > >
                        > > > > >
                        > > > > >
                        > > > > > ominique Vandensteen" <domi.vds_inser t@tralala_tenfo rce.com>[/color][/color][/color]
                        schreef[color=blue][color=green]
                        > > in[color=darkred]
                        > > > > > bericht news:OqCpfn13DH A.1392@TK2MSFTN GP11.phx.gbl...
                        > > > > > > do you want to put your query as data in a table?
                        > > > > > > if so see code
                        > > > > > > if put it in access as a stored procedure then no can do...
                        > > > > > >
                        > > > > > >
                        > > > > > >
                        > > > > > > Imports System.Data.Ole Db
                        > > > > > >
                        > > > > > >
                        > > > > > > dim conn as New[/color]
                        > > OleDbConnection ("Provider=Micr osoft.Jet.OLEDB .4.0;Data[color=darkred]
                        > > > > > > Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;")
                        > > > > > > conn.Open()
                        > > > > > > Dim cmd As SqlCommand = conn.CreateComm and()
                        > > > > > > cmd.CommandText = "insert into mytable (columnname) values ('the
                        > > > > > query...')"
                        > > > > > > cmd.ExecuteNonQ uery()
                        > > > > > > conn.Close()
                        > > > > > >
                        > > > > > >
                        > > > > > > Dominique
                        > > > > > >
                        > > > > > >
                        > > > > > > "Wim" <wim.verlinden@ pandora.be> wrote in message
                        > > > > > > news:6_9Pb.2097 9$Gf2.3930205@p hobos.telenet-ops.be...
                        > > > > > > > the access database is located at
                        > > > > > > > "C:\backup Compaq MV500\TAGS\Acce ss\2003.mdb"
                        > > > > > > >
                        > > > > > > > "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                        > > > > > > > news:fB9Pb.2094 4$Is.3846250@ph obos.telenet-ops.be...
                        > > > > > > > > Hi,
                        > > > > > > > >
                        > > > > > > > > I would like to make and put a query in my database by[/color][/color][/color]
                        VB.NET[color=blue][color=green][color=darkred]
                        > > > code.
                        > > > > > > > >
                        > > > > > > > > Is this possible?
                        > > > > > > > >
                        > > > > > > > > Thanks for your help,
                        > > > > > > > >
                        > > > > > > > > wim
                        > > > > > > > >
                        > > > > > > > >
                        > > > > > > >
                        > > > > > > >
                        > > > > > >
                        > > > > > >
                        > > > > >
                        > > > > >
                        > > > >
                        > > > >
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        • Cor

                          #13
                          Re: How to put query in database?

                          Hi Wim,

                          What is on line 63 it gives me a little bit the idea that you did make a
                          connection with the designer and that you try to overule that with a new
                          connection string. (I tried that once and that did work).

                          But it seems to me that you get an error on line 63 (because when you use
                          the designer and a form, that is at the beginning of the code).

                          Just an Idea.

                          Cor

                          [color=blue]
                          > Kan het installeerbare ISAM-bestand niet vinden.[/color]
                          Are you sure Domenique understand this?

                          :-)


                          Comment

                          • Wim

                            #14
                            Re: How to put query in database?

                            Hi Cor,


                            How can I check if I made a connection with the designer?

                            ADO.NET and VB.NET It is new to me, so maybe I make basic mistake....

                            Thanks,

                            Wim


                            "Cor" <non@non.com> schreef in bericht
                            news:%23cEBkxA4 DHA.540@tk2msft ngp13.phx.gbl.. .[color=blue]
                            > Hi Wim,
                            >
                            > What is on line 63 it gives me a little bit the idea that you did make a
                            > connection with the designer and that you try to overule that with a new
                            > connection string. (I tried that once and that did work).
                            >
                            > But it seems to me that you get an error on line 63 (because when you use
                            > the designer and a form, that is at the beginning of the code).
                            >
                            > Just an Idea.
                            >
                            > Cor
                            >
                            >[color=green]
                            > > Kan het installeerbare ISAM-bestand niet vinden.[/color]
                            > Are you sure Domenique understand this?
                            >
                            > :-)
                            >
                            >[/color]


                            Comment

                            • Wim

                              #15
                              Re: How to put query in database?

                              Cor,

                              In this other program I get also an error at conn.open

                              No error information available: DB_SEC_E_AUTH_F AILED(0x80040E4 D).
                              at System.Data.Ole Db.OleDbConnect ion.ProcessResu lts(Int32 hr)
                              at System.Data.Ole Db.OleDbConnect ion.InitializeP rovider()
                              at System.Data.Ole Db.OleDbConnect ion.Open()
                              at database_20_jan _2004.Form1.btn Database_Click( Object sender, EventArgs
                              e) in C:\Documents and Settings\Eigena ar\Mijn documenten\Visu al Studio
                              Projects\Laptop \database 20 jan 2004\Form1.vb:l ine 80

                              Private Sub btnDatabase_Cli ck(ByVal sender As System.Object, ByVal e As
                              System.EventArg s) Handles btnDatabase.Cli ck

                              Dim ds As New DataSet()

                              ds = New DataSet("import ")

                              Dim Connectionstrin g As String

                              Connectionstrin g = "Provider=Micro soft.Jet.OLEDB. 4.0;Password="" ;User
                              ID=Admin;Data Source=C:\backu p Compaq MV500\TAGS\Acce ss\2003.mdb;Mod e=Share
                              Deny None;Extended Properties="";J et OLEDB:System database="";Jet
                              OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine
                              Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk
                              Ops=2;Jet OLEDB:Global Bulk Transactions=1; Jet OLEDB:New Database
                              Password="";Jet OLEDB:Create System Database=False; Jet OLEDB:Encrypt
                              Database=False; Jet OLEDB:Don't Copy Locale on Compact=False;J et
                              OLEDB:Compact Without Replica Repair=False;Je t OLEDB:SFP=False "

                              'Connectionstri ng = "Provider=Micro soft.Jet.OLEDB. 4.0;Password="" ;User
                              ID=Admin;Data Source=C:\TAGS\ Access\2003.mdb ;Mode=Share Deny None;Extended
                              Properties="";J et OLEDB:System database="";Jet OLEDB:Registry Path="";Jet
                              OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
                              Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
                              Transactions=1; Jet OLEDB:New Database Password="";Jet OLEDB:Create System
                              Database=False; Jet OLEDB:Encrypt Database=False; Jet OLEDB:Don't Copy Locale
                              on Compact=False;J et OLEDB:Compact Without Replica Repair=False;Je t
                              OLEDB:SFP=False "

                              Dim connection1 As OleDb.OleDbConn ection = New
                              OleDb.OleDbConn ection(Connecti onstring)

                              Dim command1 As OleDb.OleDbComm and = New OleDb.OleDbComm and("Select * from
                              import")

                              command1.Comman dType = CommandType.Tex t

                              Try

                              connection1.Ope n()

                              Catch ex As Exception

                              txtError.Text = ex.Message & vbCrLf

                              txtError.Text = txtError.Text & ex.StackTrace

                              End Try

                              'command1.Conne ction = connection1

                              'Dim OleDbDataAdapte r1 As OleDb.OleDbData Adapter = New
                              OleDb.OleDbData Adapter()

                              'OleDbDataAdapt er1.SelectComma nd = command1

                              'OleDbDataAdapt er1.TableMappin gs.Add("Table", "import")

                              'OleDbDataAdapt er1.Fill(ds)

                              'Dim datagrid1 As New DataGrid()

                              'datagrid1.SetD ataBinding(ds, "import")

                              End Sub





                              "Wim" <wim.verlinden@ pandora.be> schreef in bericht
                              news:JUsPb.2254 8$5n.3785841@ph obos.telenet-ops.be...[color=blue]
                              > Hi Cor,
                              >
                              >
                              > How can I check if I made a connection with the designer?
                              >
                              > ADO.NET and VB.NET It is new to me, so maybe I make basic mistake....
                              >
                              > Thanks,
                              >
                              > Wim
                              >
                              >
                              > "Cor" <non@non.com> schreef in bericht
                              > news:%23cEBkxA4 DHA.540@tk2msft ngp13.phx.gbl.. .[color=green]
                              > > Hi Wim,
                              > >
                              > > What is on line 63 it gives me a little bit the idea that you did make a
                              > > connection with the designer and that you try to overule that with a new
                              > > connection string. (I tried that once and that did work).
                              > >
                              > > But it seems to me that you get an error on line 63 (because when you[/color][/color]
                              use[color=blue][color=green]
                              > > the designer and a form, that is at the beginning of the code).
                              > >
                              > > Just an Idea.
                              > >
                              > > Cor
                              > >
                              > >[color=darkred]
                              > > > Kan het installeerbare ISAM-bestand niet vinden.[/color]
                              > > Are you sure Domenique understand this?
                              > >
                              > > :-)
                              > >
                              > >[/color]
                              >
                              >[/color]


                              Comment

                              Working...