6 Replies - 11730 Views - Last Post: 24 May 2011 - 12:11 PM

#1 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

How do you interact with databases?

Posted 23 May 2011 - 03:29 PM

I haven't seen a thread like this before but I just wanted to pop the question. When you guys use databases in your code how do you interact with them. Do you have them embedded in the program, do you have them on a server. And how do you connect with them on a server. Do you use PHP scripts or do you connect with C# code. Just wondering what everybody generally does.

I always write a simple PHP script to echo the data back to me. A lot of times I will encrypt it and sometimes even put a password on the script so it can only be called if the password is entered as a parameter. Just wondering how all my fellow DIC heads go about this.

Is This A Good Question/Topic? 0
  • +

Replies To: How do you interact with databases?

#2 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4440
  • View blog
  • Posts: 7,721
  • Joined: 08-June 10

Re: How do you interact with databases?

Posted 23 May 2011 - 04:09 PM

That's an incredibly roundabout way of accessing data for a .NET application. For me, it depends on the app. If I'm doing a silverlight app, for example, I can't access the data directly. So I write a WCF web service that uses Linq to SQL, or EF4. Similar concept to your PHP script, but standardized, and fully inside the .NET Framework.

For client applications, I might allow it to directly access the DB, but I'd still rather use a web service if possible, since the service provides a single point of access, and I can lock my DB down to one user (that can't log in...a service account).

For embedded applications, go with an embedded DB like SQL Compact. Then you can use EF4 as an ORM.
Was This Post Helpful? 0
  • +
  • -

#3 Sergio Tapia  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1252
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

Re: How do you interact with databases?

Posted 23 May 2011 - 04:20 PM

For my school software that I sell, they typically only have 1 to 3 users at a time. So I install SQL Server 2008 on one of the more rebust machines they have, and have the other clients connect via LAN connections.

I use Entity Framework 4 as my ORM with some repository classes that let me elegantly query what I need.

I'm aching, literally aching, to implement ViewModels so I can reduce some of the cruft in my application. But I just don't have the time! New features are needed and old features need to be tweaked.
Was This Post Helpful? 0
  • +
  • -

#4 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: How do you interact with databases?

Posted 23 May 2011 - 04:59 PM

View PostCurtis Rutland, on 23 May 2011 - 07:09 PM, said:

That's an incredibly roundabout way of accessing data for a .NET application. For me, it depends on the app. If I'm doing a silverlight app, for example, I can't access the data directly. So I write a WCF web service that uses Linq to SQL, or EF4. Similar concept to your PHP script, but standardized, and fully inside the .NET Framework.

For client applications, I might allow it to directly access the DB, but I'd still rather use a web service if possible, since the service provides a single point of access, and I can lock my DB down to one user (that can't log in...a service account).

For embedded applications, go with an embedded DB like SQL Compact. Then you can use EF4 as an ORM.


Yea I know it's a little lengthy but most of the time when I use databases it's mostly on a server so I use the PHP script for security. Because I'm always worried that someone will de-obfuscate it and that will definitely not be good. Another reason that I use it, is that I'm familiar but not very good with databases in .Net. I mean I barely know anything but when I got a PHP book I would just use GET to get a parameter from a URL and it's really easy when using a WebResponce or using a WebClient and downloading a string. There are upsides to almost every way you can do it.
Was This Post Helpful? 0
  • +
  • -

#5 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4440
  • View blog
  • Posts: 7,721
  • Joined: 08-June 10

Re: How do you interact with databases?

Posted 23 May 2011 - 05:22 PM

Seriously, look into WCF. It'll save you a lot of time and effort. You don't have to write any WebRequest code at all. It's so, so much better than that. And look into using Entity Framework or LINQ to SQL as an ORM. Very, very easy and cool stuff once you get the hang of it.
Was This Post Helpful? 2
  • +
  • -

#6 MATTtheSEAHAWK  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 137
  • View blog
  • Posts: 782
  • Joined: 11-September 10

Re: How do you interact with databases?

Posted 23 May 2011 - 05:47 PM

Thanks. I will look them up soon bu I haven't had much time lately since I haven't had my laptop which is what has windows on it. I wouldn't look it up on here because I don't want to look at it and then forget because I didn't practice.
Was This Post Helpful? 0
  • +
  • -

#7 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1524
  • View blog
  • Posts: 5,957
  • Joined: 21-March 08

Re: How do you interact with databases?

Posted 24 May 2011 - 12:11 PM

Most of the code I write is for internal applications so I don't have to worry about the security part. I normally have a SQL Server instance located on a server on the network. Then my applications communicate directly to the SQL Server instance.

When I get the choice, I use Linq-To-SQL for the ORM. If I don't have a choice, I'm normally forced to use stored procedures.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1