how to open connection in oracle for displying and inserting data in asp.net with vb
how to open connection
Collapse
X
-
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. -
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
-
Problems on connection to oracle databse is resolve by using code
but on more help required how can disply data from table test thats are in addapterCode:<%@ 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>Comment
-
Thanks for your kind supports problems are now solved my full code isOriginally posted by nmsreddiHello
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
i try to know whats parts of code should be write in .vb part and .aspx partCode:<%@ 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>
thanksComment
-
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
Comment