Download code from:
https://github.com/hamza3344/desktopd...
My fiverr link: https://www.fiverr.com/hamzakhalid178
My Upwork Profile: https://www.upwork.com/freelancers/~0...
Whatsapp Number: +923338672398
if you have any problem comment below. please like, share and subscribe the channel. Contact me on [email protected] if you need any custom software, website and mobile Application.
code:
//Initization of the connectionString
private string ConnectionString = "Data Source=.\\SQLEXPRESS;initial Catalog=master;Integrated Security=true;";
private SqlCommand comd = null;
private SqlConnection conn = null;
//create the function for database
public void CreateDatabase()
{
string dir = "C:\\simpleform";
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
conn = new SqlConnection(ConnectionString);
if (conn.State != ConnectionState.Open)
conn.Open();
string sql = @"create database simpleform on primary (Name=simpleform_data,filename='C:\\simpleform\\simpleform_data.mdf',size=5,maxsize=20,filegrowth=1)";
comd = new SqlCommand(sql, conn);
comd.ExecuteNonQuery();
conn.Close();
conn.ConnectionString = "Data Source=.\\SQLEXPRESS;initial Catalog=simpleform;Integrated Security=true;";
if (conn.State != ConnectionState.Open)
conn.Open();
sql= @"CREATE TABLE [dbo].[simpletable](
[id] [int] IDENTITY(1,1) NOT NULL,
[name] [varchar](50) NOT NULL,
[location] [varchar](50) NOT NULL,
CONSTRAINT [PK_simpletable] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]";
comd = new SqlCommand(sql, conn);
comd.ExecuteNonQuery();
}
}
Смотрите видео How to install desktop application with database in client computer in c# using sql express онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь IT Core Soft 16 Январь 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 925 раз и оно понравилось 11 людям.