-
using ;
using ;
string strconnection="provider=;";
strconnection =@"data source=c:\";
oledbconnection objconnection=new oledbconnection(strconnection);
Connecting to the access database requires importing additional namespaces, so with the first two using commands, this is essential!
The strconnection variable contains the connection string required to connect to the database, specifying the data provider to be used and the data source to be used.
provider=;"It refers to the data provider, which uses the Microsoft Jet engine, that is, the data engine in Access, which is connected to the database of Access.
data source=c:\"is to indicate the location of the data source, and his standard form is"data source=mydrive:mypath\".
ps: 1." ="Behind"@"The symbol is prevented from being placed in the string that follows"\"Resolves to escape characters.
2.If the database file to be connected to is in the same directory as the current file, you can also use the following methods to connect:
strconnection ="data source=";
That saves you a lot of stuff!
3.Note that the parameters in the connection string are separated by semicolons.
oledbconnection objconnection=new oledbconnection(strconnection);"This sentence uses the defined connection string to create a link object, and we will have to deal with this object in the future operation of the database.
This is used to open the connection. At this point, the connection to the access database is complete. The rest of the operations (insert, delete.)
-
string strconnection = "provider=;
strconnection += @"data source=" + "\\";
Establish a connection. oledbconnection objconnection = new oledbconnection(strconnection);
This means that you have to put the access database file in the debug folder of the solution.
Hope mine can help you.
-
access2000-2003
Database connection string: constr ="provider=;data source = database name. mdb";
access2007-2010
Database connection string: constr ="provider=;data source = database name. accdb";
oledbconnection olecon=new oledbconnection(constr);Instantiate a database connection.
string sql="insert into table name (column name 1, column name 2) values (name, category ......)";SQL statements.
oledbcommand olecmd=new oledbcommand(sql,olecon);Execute SQL statements, etc.
Open the database.
Perform an increased method.
Close the database connection.
If you can't install SQL Server, uninstall SQL Server first, then delete the "Microsoft SQL Server" folder generated during installation, and then run the registry to put Hkey Current User Software Microsoft Microsoft SQL Server, and Hkey Local Machine Software Microsoft Microsoft SQL Server is completely deleted, (note that the entire Microsoft SQL Server folder is deleted), and then restarted.
There should be no problem with reloading!
-
If you are access2000-2003, use the following database connection string.
constr = "provider=;data source = database name. mdb";
If you are access2007-2010, use the following database connection string.
constr = @"provider=;data source = database name. accdb";
oledbconnection olecon=new oledbconnection(constr);Instantiate a database connection.
string sql="insert into table name (column name 1, column name 2) values (name, category ......)";SQL statements.
oledbcommand olecmd=new oledbcommand(sql,olecon);Execute SQL statements, etc.
Open the database.
Perform an increased method.
Close the database connection.
Add record success");
-
Go and see for yourself the next one.
-
You need to put the above three classes into your own project, and then in form1 memberbus()getmember(); Can.
-
This is what I used to turn on and off the method and it works
Open the connection.
/public void close()}
-
provider=;data source=;persist security info=false
This is access of 07
What version of yours.
-
Confirm that access is installed correctly
1. Create an access database and create a new table in the database—that is, an additional table. By setting the property values of the attached table, make it linked to the database you want to access. >>>More
Enterprise Manager Create a database in SQL Select All Tasks Import Data Select Microsoft Access from Data Source When importing the Access database to the MSSQL database, there are several issues that should be paid attention to When using MSSQL Server, there are many differences with Access, even if you use SQL Server to import the Access database, there are many places to pay attention to. 1. After importing the auto-numbering field often used in Access, it is not an auto-incrementing int, and it needs to be manually set to change the "no" of the imported auto-numbering field to "yes", and the "seed" and "increment" are both "1" in order to become an auto-number; 2. In MSSQL Server, there are many reserved words, which are not available in Access, and when you import data into MSSQL, the problem will come out. MSSQL will automatically add "[field name]" to these fields (including the table names in the database) when importing, so you must modify your script to add parentheses to the corresponding field names (or table names), or change the field names to non-MSSQL reserved words. >>>More
Well, with ADO, you can directly select and output to excel, for example, insert into [excel; database='c:\''sheet1$''(Field 1, Field 2,...)from .. >>>More
You can make an information query system, if you haven't done it before, it is recommended to use ASP to write it first, this is relatively simple, even people who do not have a basic knowledge of network programming can get started in a short period of time. The written web program can be called on the network, and different permissions can be set for different users. In this way, you can achieve the function you want, but this is only the basic, and you should learn more deeply to achieve more complete functions. >>>More
ASP connection access
Define the access database path. >>>More