Ask a questionAsk a question
 

Answerdatabase help

  • Saturday, November 07, 2009 11:05 AMnyekzz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,
    Can anyone please help me with my problem I am not sure if what I want is actually possible because I have no idea how to do this. In my project I want to create a program that uses SQL as its database. Is it possible to access the data on that table using another computer and be able to modify its data even if this other computer is located in another place? The database should also be updated as soon as there are changes done. If this is not possible can I just make a copy of the database then send it to another pc from another place then after the changes save the changes made to the original database? please somebody help me as soon as possible and please be patient with helping me because I am new with this. You can also give me helpful links that are very easy to understand or tutorials. By the way I am using visual studio 2008 (VB windows form) and SQL server 2008

    nyekzz
    I'm a noob! please help me

Answers

All Replies

  • Saturday, November 07, 2009 6:50 PMLekss Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi,

    Is it possible to access the data on that table using another computer and be able to modify its data even if this other computer is located in another place?

    You can achieve this in SQL server using LINKED SERVER . Have a read at it..


     If this is not possible can I just make a copy of the database then send it to another pc from another place then after the changes save the changes made to the original database?

    You may use conventional method of backing up the database from one environment and manually copying the backup files and restore them at the second site.
    You can also have a look at TRANSACTION LOG SHIPING for this.
    Thanks, Leks
  • Saturday, November 07, 2009 6:53 PMRaj Kasi - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Yes it is possible to connect to sql server 2008 on a remote machine, modify tables and save the changes. Here are the steps..

    1) Make sure the remote SQL Server 2008 you are connecting to is enabled for remote connections : http://www.byteblocks.com/post/2009/04/02/Configure-SQL-Server-to-allow-remote-connections.aspx

    2) There are different provider/drivers that you can use to connect to SQL Server 2008 : http://www.connectionstrings.com/sql-server-2008 . Pick one of them and then you are ready to start

    3) Lets say that you pick OledbConnection, here is an example of how you can connect and insert some data into table : http://msdn.microsoft.com/en-us/library/system.data.oledb.oledbconnection(VS.71).aspx . In the Visual Basic sample code in this link, I would replace 
    • Provider=SQLOLEDB with Provider=SQLNCLI10 
    • Data Source=localhost with Data Source = <remote server name>
    You can read more about SQL Server 2008 Native Client (SQLNCLI10) here : http://msdn.microsoft.com/en-us/library/ms130892.aspx

    I would first start with trying to connect to local server (choose provider / driver as it fits your needs), create table, insert some data, retrieve data, update and retrieve again to verify. If you get this working then connecting to remote server becomes easier

    Hope this provides you a good starting point. Please take a look and let us know if you have any questions

    This posting is provided "AS IS" with no warranties, and confers no rights
  • Sunday, November 08, 2009 1:51 AMnyekzz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi Lekss,

    Thank you for replying but seriously i didn't get any of those I couldn't understand the explanation in the links you gave me. By using linked server does it mean I have to network the two PC before they can access the database? Can't I just access it using the internet or something? I really am having a hard time understanding the concept of this. Can you please explain it to me.


    Hi Raj Kasi,

    I do know how to connect and make changes to my database using a local server, but i cant understand how I will do it with remote server. Do i really just have to put the remote server name as a replacement to localhost then everything would be fine? I know this is a really stupid question but how do I get the remote server name? Please be patient with me.

    nyekzz
    I'm a noob! please help me
  • Sunday, November 08, 2009 6:52 AMRaj Kasi - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You should be able to change the name to remote server name and be able to connect as long as you have the server setup to accept remote connections (link I mentioned in previous post).

    You should be able to use SQL Management Objects (SMO) to enumerate available SQL Servers on the network. Here are some helpful links to start with

    1. http://www.sqldbatips.com/showarticle.asp?ID=45
    2. http://groups.google.com/group/microsoft.public.sqlserver.programming/msg/caaae2403daf3d05
    3. http://www.sqlteam.com/article/finding-sql-servers-running-on-a-network
    Hope this answers your question
    This posting is provided "AS IS" with no warranties, and confers no rights
  • Sunday, November 08, 2009 7:22 AMnyekzz Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Hi Raj Kasi,

    I think your answer would only apply if the computers are in a network am i right? or i just dont understand anything sorry for my ignorance but i need guidance.
    I tried this code, I used the Internet as a way to connect them using the IP

    dim con as new sqlconnection
    con.connectionString = "Data Source = 192.168.224.1,1433; Network Library =DBMSSOCN; Initial Catalog = Rent"
    con.open()
    
    I have read some topics and all I understood was this and its suppose to work?
    but i get an error "A network related instance specific error occured while establishing a connection to SQL server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connection..." I know i am supposed to configure something in SQL but dont know what I should do can you please help me

    nyekzz
    I'm a noob! please help me
  • Sunday, November 08, 2009 2:31 PMRaj Kasi - MSFTModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    You need to look at this link (http://www.byteblocks.com/post/2009/04/02/Configure-SQL-Server-to-allow-remote-connections.aspx) and make sure SQL Server is enabled for remote connections (this link if for SQL Server 2008). If you have permissions to this machine, remote desktop/terminal server to the machine and check the steps in the link

    This posting is provided "AS IS" with no warranties, and confers no rights