Connect to database

Discussion of application development using iX Developer, including but not limited to getting started, using the functions tab, properties, objects and installation.
Post Reply
fabrice
Posts: 2
Joined: Fri Oct 07, 2011 11:03 am

Connect to database

Post by fabrice »

Hi everybody,

I got some difficulties to connect with a database (*.sdf* files).

With Microsoft SQL server 2008, I can open the database and make some SQL request.

So I have tried differents solutions to connect to the database, but I never success.

Have you some solutions or methods to connect to database.

Code: Select all

namespace Neo.ApplicationFramework.Generated
{
	using System;
	using System.Drawing;
	using System.Data;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Text;
	using System.Windows.Forms;
	using System.Data.SqlClient;
	using System.IO;

    public partial class BACKGROUND
    {
	
		
		void Button6_Click(System.Object sender, System.EventArgs e)
		{
			SqlConnection conn = new SqlConnection("Data Source=C:/Documents and Settings/fabrice/Mes documents/ECO-ENERGIE/ECO_ENERGIE/Temp/Output/Database.sdf;");
			//SqlConnection conn = new SqlConnection("Data Source=localhost;Initial Catalog=Database;Integrated Security=SSPI");
			try
			{
				conn.Open();
				MessageBox.Show("Database opened....");
				// Insert code to process data.
				
				 SqlCommand cmd = new SqlCommand("select * from ECO_ENERGIE", conn);
			}
			catch (Exception ex)
			{
				MessageBox.Show("Impossible to connect to database");
			}
			finally
			{
				conn.Close();
				MessageBox.Show("Database closed");
			}
		}
		
	}
}
Thank you in advance for your help

User avatar
Ron L.
Posts: 214
Joined: Fri Jul 15, 2011 3:21 pm

Re: Connect to database

Post by Ron L. »

This directory:

"C:/Documents and Settings/fabrice/Mes documents/ECO-ENERGIE/ECO_ENERGIE/Temp/Output/Database.sdf;");"

Looks like it my be valid for a PC. Are you developing targeting a PC platform or a terminal?
Best Regards,

Beijer Electronics, Inc.
Ron Lloyd | Applications Engineer

fabrice
Posts: 2
Joined: Fri Oct 07, 2011 11:03 am

Re: Connect to database

Post by fabrice »

Thank you for your reply.

I'm actually developping on a PC platform.

Maybe, my method is not the right one to connect with the database. Because I look on some websites other way to connect with database in C#.

Thank you.

Post Reply