Windows Application With Connection To Database On A Server
Apr 21, 2008
Hi all,
I think I can do this, just want to check
Can I have an sql server database (mdf file) on a server and allow windows applications at different site manipulate the database.
As far as I am concerned the only thing that needs to be configued is the connection string..is this correct.
[i would rather use windows applications rather than asp pages]
If I can, the best way to manipulate the database is to use stored procedures. How would I do the following to create and execute the following proposed procedure:
Insert data into a table
Update another table as a result
Execute the store procedure on a form to execute these two statements
I'moving my asp application to a new hosting server.
So when i tried the setup locally with the live DB & application in my test machine... The DB access is denied when application tries to hit the DB.
DB is in seperate machine with SQL Server 2000 & application(ASP) is in Windows server 2003..... Kindly help me with your suggestions....on what went wrong?
Hi, I am having a problem connecting my .net applications from the application server to the database server. When I run the application from my windows xp (sp2) box it works fine. When I try to connect via SQL Management Studio to the database server from the application server I get the same error. Here is the error: System.Data.SqlClient.SqlException: An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) Here is the Environment: App Server: Windows Server 2003 Standard Edition Inside Company's Firewall/ Network Database Server: Windows Server 2000 Advanced Edition SQL Server 2000 SP4 Remote Connections to the Server is checked Enable Protocols: Named Pipes & TCP/IP TCP/IP Port: 1402 (I don't know why it isn't the default of 1433) The db server is sitting out side the Company's firewall (don't ask me why). I can access it fine from inside the firewall on my XP box but not from windows server 2003. There is a web server outside the our network that also connects to the db server with no problem and that is running Windows Server 2003 Web Edition. I can ping the db server from the app server using the IP address. I tried using the IP address and the port 1402 in my connection string but that didn't work from any machine (XP and Server). I imagine the issue is somehow related to the company's firewall but why would it only block Windows Server 2003 and not XP? What do I tell the network admin to change? Any help would be appreciated. Thanks, Oran
Hi, I'm writing a windows application using VB.NET 2005 that must connect to Pocket PC via ActiveSync to read data from SQL Server CE. This is my code:
Geekz, My problem is that , I had setup blog on server say, blog.xyz.com [I am using blogengine.net, which is in ASP.Net]. It is using sql server2005 as a backend for storing its blog's posts. After settingup blog, i tried to access its database through my windows application. But while development I was getting error that "An error has occured while establishing a onnection to the server. When connecting to SQL server 2005, this failure may be caused by the fact that under the defaukt settings SQL server doesnot allow remote connections.(Provider Named Pipes, error :40 - Could not open a connection to SQL Server)" I am using [String ConnectionString = "Data Source=sql-v123.mesa11.1Server.net; Initial Catalog=abc; User ID=xyz; Password=xyz123";] Then I decided to created a webservice that will access the data from databse blog and store it somewhere in datatable and using windows application i will retrieve those data for end user. So I want to to know that whether i can access the datatable of webservice holding the blog data from windows application or not. if answer is Yes, then please provide me with source or some great links. Or if There is any other option so that I can access my database directly from windows application, then it would be better. Looking for your answers. Thanks and regards
I'm writing a Windows application (Visual Studio 2005, c#) utilizing a local SQLExpress database. It consists of about 10 tables and I've created about 15 Stored Procedures to address various functions... I can run the update Stored Procedures interactively within the designer and the data tables update as designed. However, if I run the update Stored Procedures from within my windows application is where they fail. I get no error messages, if I return a rowcount variable from the Stored Procedure it tells me that one row was updated (SELECT @RtnVal == @@rowcount)... but when I open the subject table in the designer, there is no new data.
My update queries address both insert and update functions, so if it is new row of data, it performs the insert action, otherwise it updates an existing row.
I can query the data using my stored procedures to load default values into my windows form, I can search and find client records to display in the form... I just can't update records. I'm of the opinion that it is a rights issue, but I can't find any resources that address user access accounts with SQLExpress and windows apps. The current connection string for my local database is set for Integrated Security = true; User Instance = true
I've tried two approaches... one utilizes my stored procedure....
Both fail... which points to the only common point in both approaches, the connection string and user rights... but I can't find any place to address user accounts or configurations for windows apps.
SQL Database in my application with windows authentication rejects accessing after deploying and remote access 1- My web applications databese access is windows authentication 2- In developing area there is no problem for accessing database 3- After deploying to another server there is problem accessing database: Cannot open user default database. Login failed.Login failed for user 'BRCK231ASPNET'. How can I solve this problem? Thanks.
hi i m making a win application for which i have used sql server 2005 .i faced a very big problem that i have made the database but i cannot able to connect the database with winn application .for this purpose i ned coding.so please help me.i need your help urgent.
I am attempting to write a Windows service that watches a database for uploaded files to import. When a new file is found, the corresponding SSIS package is run from the file system with variables passed through. I started development as a Windows app and copied the functionality to a service.
The app runs fine. The service does not. I get a "Failure" each time a package is executed. Everything is identical behind the scenes with the obvious exceptions that OnStart and OnStop handlers are buttons in the app. I added a script task at the beginning of one of the SSIS packages to notify me that it is even running at all. It doesn't even hit that initial task.
Again, the app will run all packages just fine. The data is imported and the results return as "Success."
The following is the code executing the package. Any help is appreciated. I've been banging my head on this one for a few days now. (Is there a tag to format a code sample?)
Dim pkgLocation As String Dim pkg As New Package Dim app As New Application Dim pkgResults As DTSExecResult
Dear members,I'am thinking about the "best" way to connect to my sql-server viaADO.Net (if there is a best way).My application uses the sql-server very intensively. At the momentevery database-operation opens a connection, executes and then closesthe connection.Another way would be to use only a single connection to the database,which is opened when the application starts.What do you think is the better way to get a high performing sqlserver: using one single application connection vs. using oneconnection for every operation?Cheers, Sebastian
Has anyone ever encountered problems making .Net applications connect to a SQL database on SQL 2000 with SP3a?
It's running on a virtual machine with a Windows Server 2000 Std with SP4, the .Net application is working with .Net Framework 1.1.4322.573. For some reason it can't connect to the SQL database using the specified username and password in the web.config file even though the user exists in the SQL database. I've tried using the SA password but this still doesn't work. I can logon to SQL Query Analyzer using the SA password but not using the other username.
The .Net application does work on other systems of mine all of which can run on Windows Server 2000 and 2003, I have compared them but can't find any differences.
Hello, I was wondering if someone could help me answer this question.
If I had a site like Yahoo, that constantly had users accessing it. Would it be a good or bad idea to automatically open a database connection to SQL Server on Application Start? What would you recommend? Would opening and closing the DB connection on every page save alot of overhead and bottleneck? Thank You.
Hi there, I have a question which I put the company that host my website but I didnt get a conclusive answer. Maybe someone here will be able to advise or help me with my situation. I want to build a database that I will run on my local server and the front end of this will be run using a windows application. I have a website which I run the database on the remote server. What I would like to do is to be able to synchronize certain tables between the two databases (such as updating products table, or orders table). I am using sql server 2005 and I am using the sql server management studio to access my database on the remote server. I did notice there is a synchronzie button. I also came across some 3rd party tools. Not sure if that is the way to go. If anyone as done this before or can give me any suggestions, I would be delighted. Thanks Anthony
I'm a database newbie, trying to decide whether to create an SQL Server or Windows Application project that uses SQL Server 2005 Express. As I understand it, the advantage of an SQL Server project is that the app deploys somehow as part of the database. If that's the case, how would I handle the scenario where the database has been updating at customer site and I need to install just a new release of the software? Would I be better of creating a Windows Application project and connecting to the database explicitly? Thank you.
I've been creating a vb.net 2005 windows form application using Everywhere and it has been going pretty well. However, I haven't had much luck finding any help on how to deploy my Everywhere database file(s) and Everywhere itself. To install redistribute Everywhere, can I just add the the 8 .dlls found in the Everywhere directory into my VS setup project? Also, what database file(s) do I need to deploy in my windows setup?
I am backing up my all the databases (around 50 servers and 500 database) using scheduled jobs. I backup my transaction log files at every two hours of interval and databases on daily basis.
I have set option of "Write to Windows Application Event Log" - When job fails during the creation of job in the "Notification Tab" of Create New Job.
As per documentation SQL server automatically records some of the events to windows application event log. After succesful completion of Log backup and DB backup, event gets logged in Windows Application Event Log. And when job fails, I get two events logged in the Windows Application Event Log file, one due to my setting and other automatically by SQL Server.
Due to this Windows event log file is growing much faster and I have to clear it in every 3-4 days.
My quesiton - Is there a way such that to get only failures event logged in Windows Application event log file and any successful backup jobs should not go to Windows application event file?
Can any suggest some idea what should I do?
I am using SQL Server 2000 with SP3 on Windows 2000 Advanced server. Some of my databases are still using Version 7.0/6.5 on NT.
I am trying to install MSDE 2.8 on this OS. When I try to install, I receive the following error: Fatal error setup This setup does not support installing on this operating system
I am developing a windows application that needs to communicate with a remote SQL server 2005 database. Server allows remote connections and MSDTC service also running. Do I need to run MSDTC service on the client machine where I use desktop application ? any ideas ? It's throwing some error like An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
But my SQL Server allows remote connection, and I am able to do a select statement. But when I insert/update anything, it's throwing this error. I guess some problem with MSDCT. Anybody have any idea ?
Hi all, I was just wonder what the normal memory consumption is when just simply making a connection to a database. I have an application that starts, and when it connects the to a database, it eats up around a 1.5 MB, yes I keep the connection open for the life of the application (as its in a kinda global class, and when database reads/writes are performed I just get the open connection object) - I don't run any queries against the database here, just connect.
Is this a normal amount of memory to consume on a simple connection to a database?
I have problem connecting to a SQL 2000 server that is hosted on a Windows 2003 server. My application uses classic ASP with VB6 components. VB6 components connect to SQL server and return data to ASP application. Everything was working fine when the application and SQL server was hosted on NT machine. Recently we have shifted to Windows 2003 server. Since then we could not establish connection to SQL2000.
I'm using UDL as connection string. IIS and SQL2000 hosted on the same machine with Windows 2003 OS. This seems to be a security issue. Earlier I faced this issue for a .net application which I resloved adding a domain account to both SQL server and IIS directory security. Request your input to solve this problem.
I have an application that is being developed on Visual Studio 2005 (VB) and SQL Express. The application is set up to use the SQL Express on the development computer, and if an Internet or CD install is built, it installs SQL Express as expected. The question is, when it is time to deploy and put the SQL Express database on the 2003 server, how should the install on the server be done and how should we set the database path to the server?
When you work with Visual Basic 2005 Express Edition on windows XP, and if your application contains references to SQL-databases, I have discovered that it is important that all identities be logged off before you open the particular identity where you want to work on your Visual Basic project. I have earlier assumed that it was only possible to work with Visual Basic on one identity, the one where the version was registered.
This assumption was not quite correct. Actually, you may run Visual Basic applications with SQL-references on all identities on XP, provided that no other identities that are using the SQL-server are currently running.
For example, suppose you start your computer and log on the identity James. Then you switch identity, but you actually don't log off James. Then you log on the John identity. There you discover that it is impossible to create a new SQL-database in Visual Basic's Data-connections view. An error message appears. Why is that? It is because the SQL-server is busy on the James-identity. To solve this problem you want to log off the John identity, don't just switch. Then log on the James identity again, and log off properly. All identities should now be logged off. Now you may log on the John identity again, and it is now possible to create an SQL database.
Concerning deploying applications for XP. This issue is similar to the one I just described. You cannot run the installation-file successfully on one identity if the SQL-sever is busy on another identity. You want to log off all identities before logging on the identity where you want to install the application. Same thing when you want to run the deployed application.
Question. Does this limitation exist only in the express-editions of Visual Studio 2005 as a drag on free-ware, or is it prevalent in commercial editions as well? I would like to know a little more about this before purchasing the standard or professional edition of Visual Studio 2005.
I just upgraded from Windows XP Pro to Windows Vista Bussiness and tried to reinstall SQL Server 2005 Developers Edition. After the installation i downloaded (using microsoft windows update) and installed all the service packs for sql and vista available.
My problem is when i open sql server management studio and try to connect to my default instance using windows authentication and database engine, an 18456 error occurs.
I enabled all the protocols and all the ports I disabled windows firewall and antivirus (eset nod32) I installed all service packs available I have also installed Visual Studio 2005 without installing sqlexpress
But nothing happens!
Please i am very desperate, any information will be gratefully accepted.
This is my installation Information
Code Snippet
Microsoft SQL Server Management Studio 9.00.3042.00 Microsoft Analysis Services Client Tools 2005.090.3042.00 Microsoft Data Access Components (MDAC) 6.0.6001.18000 (longhorn_rtm.080118-1840) Microsoft MSXML 3.0 5.0 6.0 Microsoft Internet Explorer 7.0.6001.18000 Microsoft .NET Framework 2.0.50727.1434 Operating System 6.0.6001
i have recently started to work with the analysis services and i am having some problems.
i have made a web application that for now just tries to connect to an analysis server.
The server is installed on an xp sp 2 system.
for testing, i used my local computer, which is running also win xp sp2. After deploying, the application can connect to the AS server on the other machine. the problem occurs when i try to deploy the applicatuion on the production server, which is running win 2k3 server on 32 bit. When deploying, i use the same connection string, so it should try to connect to the AS server installed on a win xp sp2 system.
The first thing that came to my mind was to check the MDAC versions, be cause of the message: "Provider cannot be found. It may not be properly installed."
on my computer, where the application worked ok, the version is MDAC 2.8 SP 1 Windows XP SP 2
on the win2k3 server, the MDAC version is : MDAC 2.8 SP2.... i thought it was the version of the service pack, so o searched for the update of MDAC 2.8 SP1, trying to install mdac 2.8 sp2 to see if i was to see the same error, but i found that mdac 2.8 sp2 is only for win2k3 server, and for win xp is mdac 2.8 sp1, according to this link: http://support.microsoft.com/default.aspx/kb/884103
Now i got confused and have no clues how to make this work...
Hey anyone, I got a problem to check a connection whether it is established or not from my C# Application to SQL Server. I am developing my application which can run in 2 modes: 1. Online: There must be a connection to SQL Server to get new data updates. 2. Offline: I dont need a connection to SQL Server. I set a timer to tick every 5 seconds and it will check the connection with SQL Server and my problem here: (this is my code)1 public static bool checkConnection() 2 { 3 SqlConnection conn = new SqlConnection("mydatasource"); 4 try 5 { 6 conn.Open(); 7 return true; 8 } 9 catch (Exception ex) { return false; } 10 }
Yes, it works but my application seems to wait about >3 seconds to get the return "False"; I tried to add "Connect TimeOut=1" in my Connection String, but the problem is still there. I dont know whether there is a faster way to check the connection to SQL server which is established or not. Thank you very much, Joesy
I have application that is connecting to SQL Server and runs bunch of stored procedures, but I don't think that am able to connect to my database server. When it hits the line to execute the stored procedure it comes up with syntax error saying the syntax error is at the stored procedure. I know how to set up the connection string with web app from the web config, but never done it on an app. Here is the connection string pointing to my server which I pass to my SqlConnection object: "Data Source=ServerXXXX;Initial Catalog=DB;Integrated Security=True; User ID=xxxx; Password=xxxx;" And that is the code that is using the above connection string: Public Sub MigrateNFSData(ByVal calcTbl As DataTable, ByVal strDBConnection As String) Dim sqlServerConn As New SqlConnection(strDBConnection) 'Define stored procedures Dim command As New SqlCommand Dim getAccID As New SqlCommand("GetAccountID", sqlServerConn) Dim getActionID As New SqlCommand("GetActionID", sqlServerConn) Dim getExchangeID As New SqlCommand("GetExchangeID", sqlServerConn) 'Dim getParrentAccID As New SqlCommand("GetParentAccID", sqlServerConn) Dim getStatusID As New SqlCommand("GetStatusID", sqlServerConn) Dim getTraderID As New SqlCommand("GetTraderID", sqlServerConn) Dim getGroupID As New SqlCommand("GetGroupID", sqlServerConn) 'Define insert records stored procedures Dim insertAcc As New SqlCommand("InsertAccount", sqlServerConn) Dim insertAction As New SqlCommand("InsertAction", sqlServerConn) Dim insertExchange As New SqlCommand("InsertExchange", sqlServerConn) Dim insertGroup As New SqlCommand("InsertGroup", sqlServerConn) Dim insertStatus As New SqlCommand("InsertStatus", sqlServerConn) Dim insertTrader As New SqlCommand("InsertTrader", sqlServerConn) Try sqlServerConn.Open() Catch ex As Exception 'Exception message goes here End Try 'Set parameters to helper Get Stored Procedures to retreive Id's getAccID.Parameters.Add("@AccName", SqlDbType.NVarChar) getAccID.CommandType = CommandType.StoredProcedure getActionID.Parameters.Add("@ActionName", SqlDbType.NVarChar) getActionID.CommandType = CommandType.StoredProcedure getExchangeID.Parameters.Add("@ExchName", SqlDbType.NVarChar) getExchangeID.CommandType = CommandType.StoredProcedure 'getParrentAccID.Parameters.Add("@ParentName", SqlDbType.NVarChar) 'getParrentAccID.CommandType = CommandType.StoredProcedure getStatusID.Parameters.Add("@StatusName", SqlDbType.NVarChar) getStatusID.CommandType = CommandType.StoredProcedure getTraderID.Parameters.Add("@TraderName", SqlDbType.NVarChar) getTraderID.CommandType = CommandType.StoredProcedure getGroupID.Parameters.Add("@GroupName", SqlDbType.NVarChar) getGroupID.CommandType = CommandType.StoredProcedure command = New SqlCommand("InsertTradeTransaction", sqlServerConn) command.CommandType = CommandType.StoredProcedure 'Set Parameters for Insert stored procedures insertAcc.Parameters.Add("@Account", SqlDbType.Text) insertAction.Parameters.Add("@ActionName", SqlDbType.Text) insertExchange.Parameters.Add("@Exchange", SqlDbType.Text) insertGroup.Parameters.Add("@Group", SqlDbType.Text) insertGroup.Parameters.Add("@ACCID", SqlDbType.Int) insertStatus.Parameters.Add("@StatusName", SqlDbType.Text) insertTrader.Parameters.Add("@Group", SqlDbType.UniqueIdentifier) insertTrader.Parameters.Add("@IP", SqlDbType.Text) insertTrader.Parameters.Add("@TraderName", SqlDbType.Text) 'Adding stored Get Stored Procedure's parameters----------------------- command.Parameters.Add("@OrderNum", SqlDbType.Text) command.Parameters.Add("@ACC_ID", SqlDbType.Int) command.Parameters.Add("@Group_ID", SqlDbType.UniqueIdentifier) command.Parameters.Add("@Trader_ID", SqlDbType.UniqueIdentifier) command.Parameters.Add("@Exch_ID", SqlDbType.Int) command.Parameters.Add("@Date", SqlDbType.DateTime) command.Parameters.Add("@Time", SqlDbType.DateTime) command.Parameters.Add("@ActionID", SqlDbType.Int) command.Parameters.Add("@StatusID", SqlDbType.Int) command.Parameters.Add("@TimeSent", SqlDbType.DateTime) command.Parameters.Add("@Qty", SqlDbType.Int) command.Parameters.Add("@Product", SqlDbType.Text) command.Parameters.Add("@MMYYY", SqlDbType.Text) command.Parameters.Add("@ExchOrderID", SqlDbType.Text) command.Parameters.Add("@TimeTicks", SqlDbType.Int) command.Parameters.Add("@W2G", SqlDbType.Int) command.Parameters.Add("@W2Exch", SqlDbType.Int) command.Parameters.Add("@G2ExchDerived", SqlDbType.Int) command.Parameters.Add("@ExchDate", SqlDbType.DateTime) 'command.Parameters.Add("@ParentID", SqlDbType.Int) 'Paremeters Defenition-------------------------------------- 'Write table with computed NFS data to sql server DB For Each dr As DataRow In calcTbl.Rows command.Parameters("@OrderNum").Value = dr.Item("OrderNo").ToString() getAccID.Parameters("@AccName").Value = dr.Item("Acct").ToString() If getAccID.ExecuteScalar() = 0 Then insertAcc.Parameters("@Account").Value = dr.Item("Acct").ToString() insertAcc.ExecuteNonQuery() //THIS IS WHERE IT FAILS and pops up with the message that there is syntax error at this procedure getAccID.Parameters("@AccName").Value = dr.Item("Acct").ToString() command.Parameters("@AccName").Value = getAccID.ExecuteScalar() Else command.Parameters("@ACC_ID").Value = getAccID.ExecuteScalar() End If getGroupID.Parameters("@GroupName").Value = dr.Item("GroupID").ToString() Try command.Parameters("@Group_ID").Value = getGroupID.ExecuteScalar() Catch ex As Exception 'Insert new Account if given account not being found from get stored procedure End Try getTraderID.Parameters("@TraderName").Value = dr.Item("TrdID").ToString() Try command.Parameters("@Trader_ID").Value = getTraderID.ExecuteScalar() Catch ex As Exception 'Insert new Account if given account not being found from get stored procedure End Try getExchangeID.Parameters("@ExchName").Value = dr.Item("Exch").ToString() Try command.Parameters("@Exch_ID").Value = getExchangeID.ExecuteScalar() Catch ex As Exception 'Insert new Account if given account not being found from get stored procedure End Try getActionID.Parameters("@ActionName").Value = dr.Item("Action").ToString() Try command.Parameters("@ActionID").Value = getActionID.ExecuteScalar() Catch ex As Exception 'Insert new Account if given account not being found from get stored procedure End Try getStatusID.Parameters("@StatusName").Value = dr.Item("Status").ToString() Try command.Parameters("@StatusID").Value = getStatusID.ExecuteScalar() Catch ex As Exception 'Insert new Account if given account not being found from get stored procedure End Try 'getParrentAccID.Parameters("@ParentName").Value = "" 'Try 'command.Parameters("@ParentID").Value = getParrentAccID.ExecuteScalar() ' Catch ex As Exception 'End Try command.Parameters("@Date").Value = DateTime.Parse(dr.Item("Exch Date").ToString()) command.Parameters("@Time").Value = DateTime.Parse(dr.Item("Time").ToString()) command.Parameters("@TimeSent").Value = DateTime.Parse(dr.Item("Time Sent").ToString()) If (dr.Item("Qty").Equals(System.DBNull.Value)) Then command.Parameters("@Qty").Value = System.DBNull.Value Else command.Parameters("@Qty").Value = Int32.Parse(dr.Item("Qty").ToString()) End If command.Parameters("@Product").Value = dr.Item("Product").ToString() command.Parameters("@MMYYY").Value = dr.Item("MMYYYY").ToString() command.Parameters("@ExchOrderID").Value = dr.Item("ExchOrderID").ToString() If (dr.Item("TimeTicks").Equals(System.DBNull.Value)) Then command.Parameters("@TimeTicks").Value = System.DBNull.Value Else command.Parameters("@TimeTicks").Value = Int32.Parse(dr.Item("TimeTicks").ToString()) End If command.Parameters("@ExchDate").Value = Date.Parse(dr.Item("Exch Date").ToString()) command.Parameters("@W2G").Value = 2 command.Parameters("@W2Exch").Value = 2 command.Parameters("@G2ExchDerived").Value = 2 command.ExecuteNonQuery() sqlServerConn.Close() Next End Sub Thank you guys as always being helpful.
I have VB6 application on several desktops connected to SERVER A (SQL Server 2005) in TESTING. I know I can change some registry values in VB6 application to connect it to SERVER B(SQL Server 20050 in PRODUCTION. but it is work on each and every desktop.
Is there any way to do something on SQL Server 2005 Engine end (like Alias) so I don't have to make changes for SERVER Redirection in each and every Desktop machine(client), and Just I make change on SERVER Side. any help or idea on that? Thanks,