473,320 Members | 2,161 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,320 software developers and data experts.

Using ODBC with C# 2005 Express Edition

Hi

I have some paradox db's i need to connect to. I have figured out that
i can do this using ODBC, however C# Express edition does not support
this connectivity easily and must be done programmatically. I have a
class to do this:

public static class Data
{
public const string SelectAllCommandText = "select * from
WindowInfo";

public static string ConnectionString;

public static DataSet GetWinInfoDataSet()
{
if (string.IsNullOrEmpty(ConnectionString))
throw new ArgumentNullException("ConnectionString");

DataSet result = new DataSet("WinInfo");

using (OdbcConnection connection = new
OdbcConnection(ConnectionString))
{
using (OdbcCommand command = new
OdbcCommand(SelectAllCommandText))
{
command.Connection = connection;
using (OdbcDataAdapter dataAdapter = new
OdbcDataAdapter(command))
{
dataAdapter.Fill(result);
connection.Close();
}
}
}
return result;
}
}

Which seems OK.
Need nelp on how to populate/bind a datagridview on my form. How can
tweak the code below to do this?

private void FormMain_Load(object sender, EventArgs e)
{

Data.ConnectionString = Settings.Default.ConnectionString;

dataSet1 = Data.GetWinInfoDataSet();
bindingSource1.DataSource =
dataSet1.Tables["WindowInfo"] ;
dataGridView1.DataSource = bindingSource1;

}
Many Thanks

Colin Williams

Jun 14 '07 #1
7 5870
On Thu, 14 Jun 2007 13:39:40 -0700, Colin Williams
<co**************@msn.comwrote:
I have some paradox db's i need to connect to. I have figured out that
i can do this using ODBC, however C# Express edition does not support
this connectivity easily and must be done programmatically. [...]
You multi-posted this to at least two different newsgroups (this one and
m.p.dotnet.framework). Please learn to cross-post properly by including
all newsgroups in the Newsgroups: field of the same post.

Thank you.
Jun 14 '07 #2
On 14 Jun, 22:40, "Peter Duniho" <NpOeStPe...@nnowslpianmk.comwrote:
On Thu, 14 Jun 2007 13:39:40 -0700, Colin Williams

<colinwilliams...@msn.comwrote:
I have some paradox db's i need to connect to. I have figured out that
i can do this using ODBC, however C# Express edition does not support
this connectivity easily and must be done programmatically. [...]

You multi-posted this to at least two different newsgroups (this one and
m.p.dotnet.framework). Please learn to cross-post properly by including
all newsgroups in the Newsgroups: field of the same post.

Thank you.
Peter

Apologies for the incovenience this must have caused. I will look into
cross posting.
Regards
Colin Williams

Experience is something you dont have until just after you need it. ;)

Jun 14 '07 #3
Colin,

It looks like it is doing it just fine. Is it not showing anything, are
you getting an exception? More information is needed.
"Colin Williams" <co**************@msn.comwrote in message
news:11**********************@i13g2000prf.googlegr oups.com...
Hi

I have some paradox db's i need to connect to. I have figured out that
i can do this using ODBC, however C# Express edition does not support
this connectivity easily and must be done programmatically. I have a
class to do this:

public static class Data
{
public const string SelectAllCommandText = "select * from
WindowInfo";

public static string ConnectionString;

public static DataSet GetWinInfoDataSet()
{
if (string.IsNullOrEmpty(ConnectionString))
throw new ArgumentNullException("ConnectionString");

DataSet result = new DataSet("WinInfo");

using (OdbcConnection connection = new
OdbcConnection(ConnectionString))
{
using (OdbcCommand command = new
OdbcCommand(SelectAllCommandText))
{
command.Connection = connection;
using (OdbcDataAdapter dataAdapter = new
OdbcDataAdapter(command))
{
dataAdapter.Fill(result);
connection.Close();
}
}
}
return result;
}
}

Which seems OK.
Need nelp on how to populate/bind a datagridview on my form. How can
tweak the code below to do this?

private void FormMain_Load(object sender, EventArgs e)
{

Data.ConnectionString = Settings.Default.ConnectionString;

dataSet1 = Data.GetWinInfoDataSet();
bindingSource1.DataSource =
dataSet1.Tables["WindowInfo"] ;
dataGridView1.DataSource = bindingSource1;

}
Many Thanks

Colin Williams
Jun 14 '07 #4
Thanks for the reply
No exceptions, but no records are being returned to the grid either.
Im stumped.

Regards

Colin Williams


On 15 Jun, 00:44, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Colin,

It looks like it is doing it just fine. Is it not showing anything, are
you getting an exception? More information is needed.

"Colin Williams" <colinwilliams...@msn.comwrote in message
Jun 15 '07 #5
Colin,

Are you sure about that? In Windows Forms, when an exception occurs in
an event handler, it is swallowed by the control. You need to wrap the code
in the Load event in a try/catch block and step through it in order to see
if there is an exception.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Colin Williams" <co**************@msn.comwrote in message
news:11**********************@q66g2000hsg.googlegr oups.com...
Thanks for the reply
No exceptions, but no records are being returned to the grid either.
Im stumped.

Regards

Colin Williams


On 15 Jun, 00:44, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>Colin,

It looks like it is doing it just fine. Is it not showing anything,
are
you getting an exception? More information is needed.

"Colin Williams" <colinwilliams...@msn.comwrote in message
Jun 15 '07 #6
Nicholas

Tried your advice and no exceptions. I have now solved the problem by
adding the table name to the dataAdapter.fill() method.
i.e
dataAdapter.Fill(result,"table name");
Many thanks for you help.

Colin Williams

On 15 Jun, 14:45, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Colin,

Are you sure about that? In Windows Forms, when an exception occurs in
an event handler, it is swallowed by the control. You need to wrap the code
in the Load event in a try/catch block and step through it in order to see
if there is an exception.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com


Jun 17 '07 #7
Now i can see the data except for the blob fields. This i anticipated.
How do i go about retrieving these?

Jun 17 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: the friendly display name | last post by:
The 2003 product line, had the standard editions, you could only work with one single language, but, ASP.NET AND windows forms development was possible, and it wasn't that dumbed down. The price...
1
by: Lubomir | last post by:
Hi, I would like to ask, how different are C# 2005 Express Edition and C# within MS Visual Studio 2005. Than as well Visual Web Developer 2005 Express Edition and ASP within MS VS 2005. ...
4
by: james | last post by:
Thought I would let everyone know that Visual Basic 2005 Express Edition is now available for download: FREE............ Until I can get Visual Studio 2005 PRO ( or maybe even Standard Edition)...
1
by: QLD_AU | last post by:
Has anyone see the following error ? VS 2005 Installs ok, however the SQL Mobile Edition (part of a full install) fails with the following error ? With Thanks Jason
1
by: Peter | last post by:
I've purchased VS.NET 2005 Standard and have tried to install SQL Server 2005 Express, but get the following error in the error log. Please could someone help me.... Microsoft SQL Server 2005...
5
by: R.A.M. | last post by:
Hello, I am learning SQL Server 2005 Expres Edition. I need to create full text index on Books.Remarks column in my database. I tried: CREATE FULLTEXT CATALOG FTC_Books AS DEFAULT CREATE...
45
by: mistral | last post by:
Does Visual C++ 2005 Express Edition produce small, compact C executables? Or there is another C compilers that do this better? m.
2
by: =?Utf-8?B?QW50aG9ueSBSb2RyaWd1ZXosIERCQQ==?= | last post by:
Hi! I downloaded MS Visual Web Developer 2005 Express Edition, MS .NET Framework SDK v2.0, and MS SQL Server 2005. Subsequently, I bought MS Visual Studio 2005 Professional Edition. 1) Are...
3
by: hsmit.home | last post by:
I spent way too much time on this and I must say, I was a little disgruntled with what has been posted on all the various Xalan C mailing lists. Everyone says there's a solution, but give next to...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.