how to open connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • idsanjeev
    New Member
    • Oct 2007
    • 241

    #1

    how to open connection

    how to open connection in oracle for displying and inserting data in asp.net with vb
  • Curtis Rutland
    Recognized Expert Specialist
    • Apr 2008
    • 3264

    #2
    Don't be lazy. Have you tried anything yet? Have you tried searching google for a tutorial yet? Connecting to oracle is no different than connecting to any other db. All you need is a different connection string.

    I'll even get you started on what to look for: OleDbConnection , OleDbCommand, and OleDbDataAdapte r. All in System.Data.Ole Db.

    Comment

    • idsanjeev
      New Member
      • Oct 2007
      • 241

      #3
      ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAt tr failed
      ERROR [01000] [Microsoft][ODBC Driver Manager] The driver doesn't support the version of ODBC behavior that the application requested (see SQLSetEnvAttr).
      ERROR [01S00] [Microsoft][ODBC driver for Oracle]Invalid connection string attribute
      Code:
      <script runat="server">
          Sub submit(sender As Object, e As EventArgs)
          dim dbconn,sql,dbcomm,dbread
          dbconn=New odbcConnection("dsn=Oracle;UserId=starter;Password=starter; " )
          dbconn.Open()
          sql="SELECT * FROM students"
          dbcomm=New odbcCommand(sql,dbconn)
          dbread=dbcomm.ExecuteReader()
          customers.DataSource=dbread
          customers.DataBind()
          dbread.Close()
          dbconn.Close()
          End Sub
      </script>

      Comment

      • idsanjeev
        New Member
        • Oct 2007
        • 241

        #4
        Problems on connection to oracle databse is resolve by using code
        Code:
        <%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
        <%@ import Namespace="System.Data.ODbc" %>
        <%@ Import Namespace=" System.Data"%>
        <script runat="server">
        sub Page_Load(sender as Object, e as EventArgs)
             Dim strConnectionString As String
                strConnectionString = "Dsn=oracle;uid=starter;pwd=starter"
                Dim pConn As New OdbcConnection(strConnectionString)
                Dim pSELECTQUERY As String = "SELECT  *from test"
                Dim adapter As New OdbcDataAdapter(pSELECTQUERY, pConn)
                Dim DS As DataSet = New DataSet()
                adapter.Fill(DS)
        		pConn.Close()
                adapter.Dispose()
            End Sub
        </script>
        
        <html>
        <head>
        </head>
        <body>
            <form runat="server">
        
            </form>
        </body>
        </html>
        but on more help required how can disply data from table test thats are in addapter

        Comment

        • nmsreddi
          Contributor
          • Jul 2006
          • 366

          #5
          Hello ,

          by looking to your code ,now the data is available in your Dataset DS,

          you can use that dataset as Datasource for your required control.

          Comment

          • idsanjeev
            New Member
            • Oct 2007
            • 241

            #6
            Originally posted by nmsreddi
            Hello ,

            by looking to your code ,now the data is available in your Dataset DS,

            you can use that dataset as Datasource for your required control.
            Yes data is in ds,but don't know how to control my data in ds to prints

            Comment

            • nmsreddi
              Contributor
              • Jul 2006
              • 366

              #7
              Hello

              what that Prints indicate , you want to print the data in DS,

              what controls you are using to display data , any GridView Control or generating report .

              what exactly you are looking for , please post complete requirement


              Regards
              nmsreddi

              Comment

              • idsanjeev
                New Member
                • Oct 2007
                • 241

                #8
                Originally posted by nmsreddi
                Hello
                what exactly you are looking for , please post complete requirement
                Regards
                nmsreddi
                I am looking for way to display data in ds with Repeater or datagrid but don't how to disply with it

                Comment

                • nmsreddi
                  Contributor
                  • Jul 2006
                  • 366

                  #9
                  Hello

                  add a gridview control then

                  GridViewcontrol 1.datasource=ds .Tables[0];
                  GridViewcontrol 1.databind();

                  thats all the data will bind to datagrid.

                  else google for binding data to DataGrid you will get plenty of example codes

                  Comment

                  • idsanjeev
                    New Member
                    • Oct 2007
                    • 241

                    #10
                    Originally posted by nmsreddi
                    Hello
                    add a gridview control then
                    GridViewcontrol 1.datasource=ds .Tables[0];
                    GridViewcontrol 1.databind();
                    thats all the data will bind to datagrid.
                    else google for binding data to DataGrid you will get plenty of example codes
                    Thanks for your kind supports problems are now solved my full code is
                    Code:
                    <%@ Page Language="VB" %>
                    <%@ import Namespace="System.Data.ODbc" %>
                    <%@ Import Namespace=" System.Data"%>
                    <script runat="server">
                    sub Page_Load(sender as Object, e as EventArgs)
                         Dim strConnectionString As String
                            strConnectionString = "Dsn=oracle;uid=starter;pwd=starter"
                            Dim pConn As New OdbcConnection(strConnectionString)
                            Dim pSELECTQUERY As String = "SELECT  *from students"
                            Dim adapter As New OdbcDataAdapter(pSELECTQUERY, pConn)
                            Dim DS As DataSet = New DataSet()
                            adapter.Fill(DS)
                             Repeater1.DataSource = ds
                            pConn.Close()
                            adapter.Dispose()
                    		Repeater1.DataBind()
                        End Sub
                    </script>
                    <html>
                    <head>
                    </head>
                    <body>
                        <form runat="server">
                            <asp:Repeater id="repeater1" runat="server">
                                <HeaderTemplate>
                                    <table border="1" width="60%">
                                        <tr bgcolor="#CCFF00">
                                            <th>
                                                ID</th>
                                            <th>
                                                Major</th>
                                            <th>
                                                First Name</th>
                                            <th>
                                                Last Name</th>
                                        </tr>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <tr bgcolor="#CCFFCC">
                                        <th>
                                            <%#Container.DataItem("id")%></th>
                                        <th>
                                            <%#Container.DataItem("major")%></th>
                                        <th>
                                            <%#Container.DataItem("first_name")%> 
                                        </th>
                                        <th>
                                            <%#Container.DataItem("last_name")%> 
                                        </th>
                                    </tr>
                                </ItemTemplate>
                    			<AlternatingItemTemplate>
                                    <tr bgcolor="#CCFFFF">
                                        <th>
                                            <%#Container.DataItem("id")%></th>
                                        <th>
                                            <%#Container.DataItem("major")%></th>
                                        <th>
                                            <%#Container.DataItem("first_name")%> 
                                        </th>
                                        <th>
                                            <%#Container.DataItem("last_name")%> 
                                        </th>
                                    </tr>
                                </AlternatingItemTemplate>
                                <FooterTemplate>
                                    </table>
                                </FooterTemplate>
                            </asp:Repeater>
                        </form>
                    </body>
                    </html>
                    i try to know whats parts of code should be write in .vb part and .aspx part
                    thanks
                    Last edited by idsanjeev; Jun 27 '08, 09:00 AM. Reason: insert code tag

                    Comment

                    • nmsreddi
                      Contributor
                      • Jul 2006
                      • 366

                      #11
                      Hello

                      all code related Vb.net should be written in .vb file nothing but codebehing

                      all the Html and scripts will be written in .aspx.

                      you can also have both the vb.net code and script in the single page ,thats what you have done .

                      while starting the application it self you have to select whether to place code in separate code behind file or not .

                      Comment

                      • idsanjeev
                        New Member
                        • Oct 2007
                        • 241

                        #12
                        Thanks
                        its outstanding supports.
                        i try to insert data in table .
                        Regards
                        jha

                        Comment

                        • nmsreddi
                          Contributor
                          • Jul 2006
                          • 366

                          #13
                          Great you are so fast ...

                          Comment

                          Working...