each web online user connect with there own acces .mdb? how to do that - asp.net

in my project, when a new user register online on my website, then my project create a directory on server with the user name "abc" and copy a myDB.mdb file in it.
this .mdb file contains predefined 2 tables.
now my question is :
1 is it possible to connect and use with Dataset.xsd in this task.
2 how each user read and write data with there own myDB.mdb file
3 how to make the connection string flexible. so it ll connect with each user myDB.mdb file.
I don't have any clue that how to complete it. i worked with dataset.xsd and vb asp.net but those were static dataset.xsd or predefined .xsd
JS

Oh, please don't do this. You really, really, really need to avoid this approach at all possible costs.
I strongly suggest that you install the free SQL Server Express, or MySQL, or any other multi-user database and store your data in there instead.
Doing this will preserve your sanity both when creating the initial implementation and when you have to update a column or a table in all of the MDBs that have been created for your end users.

Related

insert into database automatically creating a folder

I was just wondering if this is possible. I have a site that admins use to add products to our database. The database is in SQL Server 2008 and I use Visual Studio 2010 using VB.net and was hoping that upon addition of a new product, it would automatically generate a folder assigned to that product's ID.
I haven't found anything online that would suggest that this is a possibility, but it would make it a lot easier for me. As of right now, I have to remember to create a folder in the X: drive for each product that has been added. We are up to 645 products now, so you can see my need for some kind of automation here.
Any kind of help would be greatly appreciated!
If you're using a web service or web project to create products, you could create the directory there when the user enters a new product.
Dim dir As New System.IO.DirectoryInfo("C:\" & someFolder)
If Not dir.Exists Then
dir.Create()
End If
If products are always added within a call to a stored procedure, you could add code to call xp_cmdshell to "MD < DirName >" after the insertion. If not done via stored procedures, you could do something similar in an insert trigger. However, both of these are really bad ideas. SQL is first and foremost a database engine, not a file system manager or flexible programming tool. You are much better off having the application(s) that cause the creation of products be responsible for manipulating files and folders on your hard drives.

How to push data from excel to SQL Server?

I have written a simple ASP.NET MVC 2 application that stores data and can dynamically create excel files using Microsoft's openXML for excel files.
What is the best way to push changes the user makes in excel to my database? I know it can be done via file upload, but this is rather obtrusive to the end user to navigate to my site, select upload, and then select their file.
Is there a way to do 1 click publishing from the excel file using VBA? VBA can interact with the database directly, but this seems dangerous from a data security standpoint, and duplication of logic.
Do web services work with the MVC architecture? How do I get a vba macro enabled document to send itself to the server?
For anyone out there looking for a fix, I ended up using vba's InternetExplorer.Application object and interacting with an upload form on my site.
For more info on the upload form check out:
http://haacked.com/archive/2010/07/16/uploading-files-with-aspnetmvc.aspx
For more info on VBA and the InternetExplorer.Application object check out:
www.motobit.com/tips/detpg_uploadvbaie/
You might take a look at Sql server integration services for bulk upload of data into sql server. The integration services once created can be run using a normal c# desktop program or using a windows service.
But you might
need to make sure this happens in the background and will have to be
an asynchronous task.
also need to make sure it is properly secured
by not giving direct execute access to any other users
I'm assuming that this is for a specific user. I've done something very similar to what you are describing before.
Tell the user to save the excel file in their DropBox and share the file with you.
Have the server listen for changes to this file and run a server side routine to import the data.
Disclaimer: This is not a secure solution, but it's easy and will get the job done.

Uploading A SQL Server Script?

My over all goal is to upload a very simple ASP.NET web site created in C# and using a SQLEXPRESS DB to a hosting provider via FTP.
I understand that I can get all of my ASPX, .CS, master pages and image files with no problem. Problem I am having and reason I am here is because I cant simply pop my MDF file into my hosting provider's (Verio Hosting) site.
On the web I ran across a post by Scott Gu. In his post he wrote about converting a MDF into a .SQL file which you can execute from a web site. See below....
If your hoster has no usable HTML web
admin tool for allowing you to easily
manage your SQL database, then you can
also just write a simple ASP.NET page
that you FTP (along with your .SQL
file) to your web-site and then hit to
read the .SQL file on the server in as
text, and then pass it as a string to
ADO.NET to execute. This will give
you the same result as the query
analyzer above - and fully create your
database for you.
I created the .SQL file and I am capable of popping this .SQL file into my website. My question to you guys is how do I create that simple ASP.NET page that I can then hit to read, and then do everything else that Scott mentioned in the passage above????
EDIT: I found out that that I can just re-create my DB by remotely logging in to my hosting providers SQL server via SQL Mgt Studio. I dont want to do this for two reasons 1.) It feels cheap knowing that there is a much cooler way to do this, and 2.) I dont know how to re-create the ASPNETDB.MDF that I use for my user database that ASP.NET created for me.
My question to you guys is how do I
create that simple ASP.NET page that I
can then hit to read, and then do
everything else that Scott mentioned
in the passage above????
Which part of the process don't you understand?
It's just a regular *.aspx web form; you do all of the work in the code behind.
BTW, when sending commands to SQL Server via ADO.NET, keep in mind that ADO.NET doesn't understand "GO" statements; if your script contains them, you will either have to parse them out and submit batches accordingly, or arrange to invoke a command-line tool like sqlcmd from your page, if your hosting provider allows it.
You simply need to have the ASP page read in the .SQL file, which is a series of SQL queries to be executed. Loop though the contents of the file, running each query in turn. The queries will create the db schema, insert the data, etc.

ASP/ASP.net: Web-based JET database management tool?

I need to manipulate some tables in a JET database housed on a web-server:
check existing indexes
change table cluster/primary key
see what tables exist
rename tables
add tables
drop tables
browse data
etc
I don't have the option of installing PlaneDisaster or Access (even if i had it) on the local machine.
I've already written a generic web-based query tool. I'd rather not have to get into writing a whole web-based database maintenance GUI. Someone must have done this already, and probably many times over.
A partial answer might be Compare'Em
http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEMscreens/CompareEM-About.htm The Pro version allows you to create SQL statements to update the Access database file. This will allow you to generate the differences between one version and a newer version.
His website isn't very clear but as I recall the price for the Pro version was $10.
As you say you have already done a generic web based query tool. The problem with JET is that you cannot connect with it as database server like you can do with one SQL server in order to process changes to tables and other maintenance procedures. Jet is is not a client/server RDBMS. You need to have an application in the server to do that for you as you already have done with your generic web based tool, or download the database to your machine. That's why you have done some procedures and locate them in the server as asp pages.
Anyway you can use JetSQLConsole, if you don't want to use Planedisaster or Access, but remember that you need always an application on the server to to the job for you
You can also use access "in your machine" and connect to a database located in a URL (http://myserver/mydatabase.mdb) but remember when you are doing this you are downloading all the database and when you save it you are uploading it again.

How to create a database and populate it during setup

I would like to find a way to create and populate a database during asp.net setup.
So, what I'm willing to do is:
Create the database during the setup
Populate the database with some initial data (country codes or something like that)
Create the appropriate connection string in the configuration file
I'm using .NET 3.5 and Visual Studio 2005, and the Database is SQL Server 2005.
Thanks in advance.
If you are creating an installer I'm sure there is a way to do it in there, but I am not all that familiar with that.
Otherwise, what you might do is the following.
Add a application_start handler in the Global.asax, check for valid connection string, if it doesn't exist, continue to step two.
Login to the server using a default connection string
Execute the needed scripts to create the database and objects needed.
Update the web.config with the connection information
The key here is determining what the "default" connection string is. Possibly a second configuration value.
Generally, you'll need to have SQL scripts to do this. I tend to do this anyway, as it makes maintaining and versioning the database much easier in the long run.
The core idea is, upon running the setup program, you'll have a custom action to execute this script. The user executing your setup will need permissions to:
Create a database
Create tables and other database-level objects in the newly-created database
Populate data
Your scripts will take care of all of that, though. You'll have a CREATE DATABASE command, the appropriate CREATE SCHEMA, CREATE TABLE, CREATE VIEW, etc. commands, and then after the schema is built, the appropriate INSERT statements to populate the data.
I normally break this into multiple scripts, but YMMV:
Create schema script
"Common scripts" (one for the equivalent of aspnet_regsql for web projects, one with the creation of the Enterprise Library logging tables and procs)
Create stored procedure script, if necessary (to be executed after the schema's created)
Populate initial data script
For future maintenance, I create upgrade scripts where a single script typically handles the entire upgrade process.
When writing the scripts, be sure to use the appropriate safety checks (IF EXISTS, etc) before creating objects. And I tend to make mine transactional, as well.
Good luck!
Well, actually I found a tutorial on MSDN: Walkthrough: Using a Custom Action to Create a Database at Installation
I'll use that and see how it goes, thanks for your help guys, I'll let you know how it goes.
If you can use Linq to Sql then this is easy.
Just import your entire database into the Linq to Sql designer. This will create objects that describe all objects in your database, including the System.Data.Linq.DataContext derived class that encapsulate the entire database setup.
Now you can call DataContext.CreateDatabase() to create the database.
See here more information.

Resources