473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Database creation in SQL 2005 from C# - works from one computer, not the other

Was hoping someone could give me some things to check here - I'm trying to figure this one out.

I've got a SQL connection string in an INI file, it is read into my C# .NET console app and connects to the database fine from my workstation. It processes the SqlCommand statements I use to drop the table (if it exists) and re-create it, and does an Insert statement to fill one row, and quits. This all works fine from my workstation (running XP) when ran on the command line.

When I copy it over to our IIS server (running W2K3) and run it the same way, using the same INI file, same DB connection string to hit the same SQL server it was able to create the DB on before, it does not work. Any thoughts on why this might happen? I'm logged in as me on both my workstation and the server, and my account has DB creation and admin rights on the SQL server. I have another console app on the IIS server that can hit that SQL server fine. At a loss here.

Thanks,
Tom
Aug 17 '09 #1
5 1973
tlhintoq
3,525 Expert 2GB
it does not work.
A bit vague.

Logging. It's hard to create *too much* logging in a program. Give your program a ton of logging. I'll bet that most of your methods do a "console.writeline()" from when you were building and debugging it, so you could see where something worked and didn't. Those things are a good start on what to write to a log file.

I'd bet it will come down to something simple and easy to overlook like an extra '\' in a path etc. But it will be hard to find unless you log attempts and responses:

12:31.123: Attempt to connect to "http:\\mydatabase.sql"
12:31.666: Connection failed: "wrong password"
Aug 17 '09 #2
Thanks for the quick response. Yeah, I agree that was a little vague.

What I meant to say is that my program seemed to go through all of the motions, but not create the database or tables. I thought my "Console.WriteLine" statements completed as they should, but it turned out I did need more in there - I had them before and after the call to the class that contains the SqlCommands that create the tables, before, and these would write fine. So I put them right after the ExecuteNonQuery statements on my SqlCommands that created the tables, and these DID NOT write. I have it write the error from any SqlException that could come up to the Event Log, but nothing gets written. What would cause the tables not to write, but no exception to be raised?

Thanks,
Tom
Aug 18 '09 #3
tlhintoq
3,525 Expert 2GB
So I put them right after the ExecuteNonQuery statements on my SqlCommands that created the tables, and these DID NOT write.
I'm going to guess some exception occured and the code aborted, so it didn't make it to the line writing the error condition.

What would cause the tables not to write, but no exception to be raised?
Invalid path
Invalid command
Aug 18 '09 #4
The ExecuteNonQuery statements are inside of a try...catch, so if there was an exception raised, the event would be logged since the EventLog routine is inside of my catch (wouldn't it?). I know the SqlCommands are valid since they will write the tables when the app is run from my workstation. All I'm doing is moving the app from my workstation to a server - I keep everything the same (connection string in the INI file, other INI settings). What could cause it not to perform the table creation SqlCommands from the server when it can do them from the workstation? Are there client-side OS settings that should be re-configured or something?

Thanks,
Tom
Aug 19 '09 #5
Actually I figured out later it involved the accounts I was running the app under. On my local dev machine it was running under my service account's privileges. When I moved it to the server, I found out it was under the Network Service account, not carrying over the service account's privileges due to a double-hop issue. Surprised it didn't raise a security exception, but it didn't. So it was a lot more complicated than just not writing to the Event Log or console. I solved it by impersonating the service account before it opened the database connections.
Jul 26 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: John Bunch | last post by:
I have installed Visual Studio 2005 Team Suite Beta 2, including SQL Server 2005 Express Edition April CTP, on Windows XP Professional SP2, including IIS 5.1. The SQL Server (SQLEXRPESS) service...
12
by: dennist685 | last post by:
How to get an Access database on the web from my own computer I have an Access database project in inetpub/wwwroot/Access2 . I build it, and then press cntrl-F5. - I still get the development...
4
by: robert d via AccessMonster.com | last post by:
When my app starts up, it creates a temporary database. This temp database is created from a 'model' database that is in the same folder as the application. Because there is a model, the creation...
0
by: Jonathan Wood | last post by:
I seem to be having errors creating and accessing an SQL database. Unfortunatley, I am brand new to SQL setup and administration issues so this really is not my area of expertise. I know I had...
2
by: Tor Inge Rislaa | last post by:
Database on remote server On the remote server where my ASP.NET application is located there is no SQL Server or SQL Server Express. When I test my application locally it works fine because...
0
by: jsaccomanno | last post by:
NeoEdge Networks www.neoedge.com We're looking for a Senior Database Administrator, for our office in Toronto, Ontario Canada. Position Description · Responsible for ongoing development...
0
by: Orgil | last post by:
Hi all, I have just writing a program named "DayBook". I am using MS Access 2003 database and Microsoft .NET C# 2005 (with framework 2.0). MS Access 2003, MS .NET C# 2005 and dotNetFramework2.0...
8
by: BD | last post by:
I am developing C# win form app to work with remote database on SQL Server 2005. Problem scenario is as follows: 1. a form is open that has downloaded dataset to local cache 2. computer is...
31
by: Tom P. | last post by:
I am doing quite a bit of custom painting and it means I have to create a lot of brushes (think one for every file system object in a directory) per paint. How expensive is this? Should I find a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.