
August 12th, 2005, 06:27 AM
|
|
Registered User
|
|
Join Date: Aug 2005
Posts: 1
Time spent in forums: 1 h 16 m 50 sec
Reputation Power: 0
|
|
problem creating a new database from asp.net
Hey guys. Very new to all this. Trying to learn. My current project is to build a website that can be accessed by my friends. I have (briefly) designed a page or two to accept their details and passed this information to an aspx page. I am now trying to cause this page to create a new database, the aim being to store their information in this database. The problem I have is that when I try to use the code
Dim dbconn As OleDbConnection
Dim dbcomm As OleDbCommand
Dim sql As String
dbconn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & Server.MapPath("user_records.mdb"))
dbcomm = New OleDbCommand("CREATE DATABASE user_records.mdb")
dbcomm.ExecuteNonQuery()
I get the error:
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: ExecuteNonQuery: Connection property has not been initialized.
---------------------------------------------------
Obviously, when I reverse things to open a connection first I get told that the file I'm trying to connect to doesn't exist.
What am I missing? I'm sure it's something really simple, but the help files are appalling and everything is quite confusing when you're starting out... Does anyone remember programs that went like this (BASIC from the 1980s):
10 REM NEW PROGRAM:
20 INPUT "What is your name";a:
Actually, don't worry. I've found a copy of access and created a database there which is easily accessed by my meagre programming skills. Thanks anyhow.
Last edited by bwt1978 : August 13th, 2005 at 09:05 AM.
Reason: fixed problem
|