Learning. NET encountered problems: Database access Connectivity Issues

Source: Internet
Author: User
Access | data | database | problem | Learning Error One: The following error occurred while running the code:
-------------------------------------------------------------------
Compiler error message: BC30002: undefined type ' adoconnection '.

SOURCE Error:
Line one: <script language= "VB" runat= "Server" >
Row 12:sub button1_click (sender as Object, E as EventArgs)
Row 13:dim CnA as Adoconnection=new adoconnection
Line 14:dim CmA as Adocommand=new Adocommand
Line 15:cna.provider= "Microsoft.Jet.OLEDB.4.0"
Source file: G:\inetpub\wwwroot\WebApplication1\WebForm3.aspx line: 13
-----------------------------------------------------------------------------
This is because namespace wrong!
Use the following:
<%@ import namespace= "System.Data"%>
<%@ import namespace= "System.data.Oledb"%>
The corresponding variable is declared as:
Dim myconn As OleDbConnection
Dim mycommand As OleDbCommand

<%@ import namespace= "System.Data"%>
<%@ import namespace= "System.data.SqlClient"%>
The corresponding variable is declared as:
Dim myconn As SqlConnection
Dim mycommand As SqlCommand

<%@ import namespace= "System.Data"%>
<%@ import namespace= "System.data.ODBC"%>
The corresponding variable is declared as:
Dim myconn As OdbcConnection
Dim mycommand As OdbcCommand

The test procedures are as follows:
=============================
<%@ import namespace= "System.Data"%>
<%@ import namespace= "System.data.Oledb"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<BODY>
<script language= "VB" runat= "Server" >
Sub Page_Load (Sender as Object, E as EventArgs)
Dim ds As DataSet
Dim myconn As OleDbConnection
Dim mycommand As OleDbCommand
Myconn=new OleDbConnection ("Provider=sqloledb; Data source= (local); Uid=sa; Pwd=pssword; Initial catalog=database ")
MyConn.Open ()
Mycommand=new OleDbCommand ("SELECT * from User_info", myconn)
Dim myreader as OleDbDataReader = Mycommand.executereader (commandbehavior.closeconnection)
DataGrid1.DataSource =myreader
Datagrid1.databind ()
End Sub
</script>
<P>
<meta content= "Microsoft Visual Studio. NET 7.1" name= "generator" >
<font face= "Song Body" >
<asp:datagrid id= "DATAGRID1" runat= "Server" ></asp:datagrid></FONT>
<meta content= "Visual Basic. NET 7.1" name= "Code_language" >
<meta content= "JavaScript" name= "vs_defaultClientScript" >
<meta content= "http://schemas.microsoft.com/intellisense/ie5" name= "Vs_targetschema" >
</P>
</BODY>
</HTML>

==============================
<%@ import namespace= "System.Data"%>
<%@ import namespace= "System.data.SqlClient"%>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<BODY>
<script language= "VB" runat= "Server" >
Sub Page_Load (Sender as Object, E as EventArgs)
Dim ds As DataSet
Dim myconn As SqlConnection
Dim mycommand As SqlCommand
Myconn=new SqlConnection ("server=" (local); Uid=sa; Pwd=huangfeng;database=jxjyzb ")
MyConn.Open ()
Mycommand=new Sqlcommand ("SELECT * from User_info", myconn)
Dim myreader As SqlDataReader = Mycommand.executereader (C

[1] [2] [3] Next page



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.