Click here to Skip to main content
15,031,937 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, i have developed a window application with sql server 2005. i want to create an web application with same database which my window application uses. how can i do this task.

can we sync local database with web server database.
can my web apps uses the local database.
can my window apps uses the web server database. please help me
Posted
Comments
[no name] 26-Sep-13 10:04am
   
Why do all of that? Why don't you just use the same database?
harry_rana 26-Sep-13 10:10am
   
can we use the same local database for the web as well as window application
my window application is running. but how can we use same database in web application.
[no name] 26-Sep-13 10:37am
   
By pointing your web application to the same database.
harry_rana 26-Sep-13 10:18am
   
can we use the same local database for the web as well as window application my window application is running. but how can we use same database in web application.what is the connection string for it.should i use ip add with port num
Rick van Woudenberg 26-Sep-13 10:09am
   
clueless.
safzal1212 26-Sep-13 10:28am
   
Is your database on local machine or on any server in your network? When you say that "Can my web app use the local database" then what do you mean by that?
harry_rana 26-Sep-13 10:29am
   
local machine
safzal1212 26-Sep-13 10:34am
   
Web application can also access the database from your local machine but it's not a good idea. You can put your database on a server or at any machine in your network. Your desktop application can access the centralized database by just changing the connection string and your web application will also be able to access the centralized db through it's connection string.
harry_rana 26-Sep-13 10:35am
   
ok, but what is the connection string in both cases. should i used same connection string
safzal1212 26-Sep-13 10:43am
   
How is your application accessing the database? You should have "app.config" file in your code that have some kind of connection string to build a conntion between your application and database. Coonection string look something like this <connectionstrings> <add name="esample.Properties.Settings.devtestConnectionString" providername="System.Data.SqlClient" connectionstring="Data Source=MachineName;Initial Catalog=DatabaseName;Integrated Security=True">

harry_rana 26-Sep-13 10:57am
   
conn.ConnectionString = "Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=UCMS_EmpSalary;Data Source=KATARIA\\SQLEXPRESS";
safzal1212 26-Sep-13 11:06am
   
Yup, so your web application can also use the same connection string in it's web.config and if you decide to put your database on some other machine in your network then just change the Data Source=KATARIA\\SQLEXPRESS part of your connection string in both of your apps.
harry_rana 26-Sep-13 11:16am
   
dat mean i dont need to change my connection string. how my web application which is running on other server uses same database with same connection string. i think i should use ip add and port num for connecting my web apps to local database or centralised database
safzal1212 26-Sep-13 11:28am
   
if your web server and your machine is on same netwrk then I believe you should be able to access using name or IP both.
harry_rana 26-Sep-13 11:33am
   
if we have different server. then i think ipaddress and port number combination works

1 solution

The application connects to the database - and it does not matter whether that's a Windows Forms application or a Web Application. Look at the connection string: there you tell the application where the SQL Server can be found, and the credentials for login to the SQL Server.
But there is one point you should take into consideration: if your Web application is available via the internet (i.e. not only intranet of a company), then security is crucial.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900