How to Create mysql database Dynamically in asp.net - c#

I want create Mysql data base in asp.net (c#) as Dynamically.My task is when user login then automatically create Mysql database with username and save into my serverpath(App_Data). Actually i am not femiliar with mysql database.. please help me how to create this.....

If your purpose is being able to deploy the DB with the application just by copying it on the server (as you're implying with the reference to app_data) then MySQL is not the right database choice. You can't deploy a MySQL database just by copying the underlying files.
You probably want an in-process engine, like Sqlite, Sql Server Compact Edition or even MS Access.
If your request, however, is to use MySQL as a db for users and roles (but you understand that you will need to setup MySql and create the DB on the server before using it, as it will not be copied with your web application), then you can take a look at this question: ASP.NET Membership/Role providers for MySQL?

Related

What is the best way to synchronize my local mysql Database with online mysql Database

What is the best way to synchronize my local mysql Database with online mysql Database using C# (Any Other solution except creating mysql Dump locally and than restore it on online mysql server).
You can use FEDERATED Storage Engine locally.
Not saying it is the best but it is easy to setup.
If your MySQL server version is already compiled with federated engine support what MySQL Windows versions seams to have.
The FEDERATED storage engine lets you access data from a remote MySQL
database without using replication or cluster technology. Querying a
local FEDERATED table automatically pulls the data from the remote
(federated) tables. No data is stored on the local tables.
source https://dev.mysql.com/doc/refman/8.0/en/federated-storage-engine.html
But you need to check if your MySQL version supports it and FEDERATED storage engine is actived.
SHOW ENGINES;
Only think is need to make a table copy from every table and make it FEDERATED storage engine.
Best is to make a separated database for it.
Here is a create table example.
CREATE TABLE `T1`(`A` VARCHAR(100),UNIQUE KEY(`A`(30)))
ENGINE=FEDERATED
CONNECTION='MYSQL://127.0.0.1:3306/TEST/T1';
Then you can insert, update and delete from that table
I suggest you to use MySQL Replication feature.
Replication enables data from one MySQL database server (the master) to be copied to one or more MySQL database servers (the slaves). Replication is asynchronous by default; slaves do not need to be connected permanently to receive updates from the master. Depending on the configuration, you can replicate all databases, selected databases, or even selected tables within a database.
You can find more information at the MySQL official website

Do I have to install sql server on each client to use my disk top application?

I have a disk top application made by c# visual studio. My question is do I have to setup SQL server on each client to use my application? or there is another way to attach my database with my application and compress it as one and send to each client and those just extract that file and use the application correctly?
On a real scenario, your database should be placed on a remote server and the clients should only access the database through your API (that will need to support authentication or any other identity based systems).
If your application only needs to store some local information (relevant only for your client app), then you can just use LocalDB or AppSettings, depending on your data structure.
Otherwise, if your application contains more complex features, then you will need an API and a remote DB managed only by you.
To conclude, you only need to setup Sql Server once, when you want to create the design of it (tables, columns, links). The clients will only have to connect to it and pull their data. And this task can be done without installing SqlServer. This link shows you that you only need System. Data assembly to connect to a Sql Server DB.
Yes you need to instal SQL server on each machine or if you go for LocalDB then also u need to instal SQL server engine ,and you have a better option u need to buy sqlserver from AZURE (it's free for one month try if want click here AZURE)

C# Sql-server on every client

I want to build an application that needs a sql database on every machine that uses the application.
Isn't it true that Chrome and Firefox store cookies in a SQL database? I did not remember installing anything like a SQL server while installing Chrome, so my question is: does every user has to install a SQL Server if my app uses one?
The best thing for your purpose is to use database servers, which will be started with your application, like SQLite or Sql Server Compact. That means, you application host the database it self and you have access over ADO.Net. This is a very smart kind of storing local data and very easy.
Do not try to install complex database systems like mssql, sybase or mysql on every client.
For example, SQLite can be delivered with a few assemblies in your product.
This answers gives a nice overview: Lightweight SQL database which doesn't require installation
In order to store information for a client application, you can use SQL Server Compact, or some other solution, like SQLite (with a library to access it).
There are other alternatives, but these two are the most common and stable.
It's true that Firefox stores cookies in a sqlite database. However, that's not the same thing as SQL Server.
If your app needs to communicate with a database, you can a) bundle a sqlite database with it, b) require an existing database on startup (Wordpress does this; you can pass it details for a mysql database to get it to use an existing installation), or c) bundle a full database (like SQL Server Compact) with your application.

MVC 3 C# - Deployment and MYSQL Database

Visual Studio 2010 - C# - MVC3
I am completely new to ASP.Net and I have been working / practising making an MVC 3 application using C#. I have practised getting an MVC application online which makes use of no databases and was successful. My hosting supports .net 4 and it was a simple process of publishing the files and uploading to my FTP. I am making a new application which makes use of a database. I have set up a data connection in the server explorer and set up all my tables and relationships. Everything is currently working as intended and I can create, edit and delete entries from the database.
I am not really sure where to start with getting this online. My hosting offers no MSSQL databases so I am presuming I can use a MYSQL database? What is the process of changing my application to use a MYSQL database which is located on my remote hosting? Also I am making use of the default accounts where users can register and login, will I have to set up a database for this too?
Your host offers mysql hosting?
you will need the mysql .net connectors.
also check this next out for the asp.net membership, mvc uses
http://dev.mysql.com/doc/refman/5.1/en/connector-net-tutorials-asp-roles.html
You can use a local DB in your APP_DATA folder or you can connect to a remote DB. Please let me know if you need additional help in either of these two areas or if I have misunderstood your question. You may also want to encrypt your web.config file to secure your DB passwords better.
From our chat:
Try this stackoverflow.com/questions/…
SQL CE supports binary deployment, meaning your hosted doesn't have to have anything installed and you get SQL support, however no stored procedure support (if that matters to you here)
In addition you can install the SQL Compact Toolbox into Visual Studio
http://sqlcetoolbox.codeplex.com/
See: http://blogs.msdn.com/b/webdev/archive/2011/01/06/how-to-bin-deploy-sql-compact-edition-4-0-and-razor-web-projects.aspx

How to use LINQ for standard C# application with local database file?

I'm used to work with ASP.NET and I have no problems there, but now I need to create a C# Console application and something is wrong.
I create console application
Add new item to project (Local database)
Fill in some basic data (id, name)
But when I create LINQ to SQL Class and drag my table to it like I do in ASP.NET I get error
The selected objects use an unsupported data provider
What am I doing wrong here, how can I make my work with databases using C# Console/Windows application as fast and easy as with ASP.NET applications?
The database driver / provider needs to allow for the usage of linq. If you are using a simple sqlite db, I would recommend using the DBLinq provider.
If you are using Microsoft's lightweight database (Sql Compact) then I believe this article maybe helpful.
The Object Relational Designer (O/R Designer) supports only the .NET Framework Data Provider for SQL Server ( System.Data.SqlClient).
Where as sdf local DB is a Compact Database. SQL Server Compact Edition (System.Data.SqlServerCe) is not supported by O/R Designer.
Instead you can create a db in SQLExpress and connect to Designer

Categories