Page 1 of 2

ADO.NET Database Access Tutorial

Posted: Mon Jan 16, 2006 7:51 pm
by 9639842
While following Tutorial 8 (ADO.NET Database Access) I am unable to connect to a database. When I get to step 10 in the tutorial, as soon as I select "oleDbDataAdapter1[System.Data.OleDb.OleDbDataAdapter]" from the ComboBox I am immediately kicked out of the TeeChart editor and taken back to the Windows Form window (Form1). I am using MS Visual Studio 2005. Is the tutorial not up to date with the latest version of Visual Studio? I can't seem to figure out how to get TeeChart to read from a database. Any help would be appreciated.

Thanks.

Posted: Tue Jan 17, 2006 11:27 am
by narcis
Hi bsindorf,

Visual Studio .NET 2005 doesn't have oleDBDataAdapter. However, I've created a VS.NET 2003 project and upgraded it to VS.NET 2005 and worked fine. Your problem with VS.NET 2005 may be with BindingSource. If that's your case you should try using latest Debug Build, available at our Customer Download Area, which includes BindingSource support. Otherwise, could you please be more specific about your problem?

Posted: Tue Jan 17, 2006 3:19 pm
by 9639842
Thank you for the quick response. However, there is an oleDbDataAdapter in Visual Studio 2005 (note that I am creating a windows application, not a web site). Basically what I am looking for is a tutorial for using a database with TeeChart .NET. I am new to both TeeChart and to VS.NET 2005. Are there any examples or tutorials that work with VS.NET 2005 that may help me?

Also on a related note, I cannot edit TeeChart data manually using the TeeChart editor within a VS.NET form. It automatically sets the data source to random upon exiting the editor. Is this a problem with TeeChart or with VS.NET 2005?

Thanks.

Posted: Fri Jan 20, 2006 1:07 pm
by narcis
Hi bsindorf,

In Visual Studio 2005 you should try using BindingSource:

1) Go to Data tab and select "Show Data Sources".
2) Right-click on the Data Sources toolbox and select "Add New Data Source".
3) Select Database, select/create the connection string and finally select the tables you want to connect.
4) Select the table you want to use as data source from the Data Sources toolbox and drag it to your form.
5) Now set the dragged data source as the data source for your series as you could do with Visual Studio 2003.
Also on a related note, I cannot edit TeeChart data manually using the TeeChart editor within a VS.NET form. It automatically sets the data source to random upon exiting the editor. Is this a problem with TeeChart or with VS.NET 2005?
This is as designed as for now this is only available for visualizating.

Visual Studio 2005 and DataBinding WAS ADO.NET Database Acce

Posted: Thu May 25, 2006 8:12 pm
by 9640386
Hello,

I've been trying to get DataBinding working with TChart and Visual Studio 2005. I downloaded the Debug version of TeeChart.NET and installed it. I then created a new project in VS2005, added a WinForm, added a TChart, added a data source and created a DataBinding. I can create a DataGridView and populate it on the form using the DataSource, so the connection to the database seems to be working fine. When I try to edit the Series in the TChart, I run into problems. I edit the series and choose the Data Source tab and then choose Database. The Dataset pulldown shows my .NET DataSource and I can select column names from the database for my X and Y variables. Then when I hit the Apply button, the TChart jumps back to random data! This happens with both the production and debug versions of TChart.NET. Any suggestions as to what I ought to try next?

cheers, Paul

Posted: Fri May 26, 2006 10:19 am
by narcis
Hi Paul,

You should try using series CheckDataSource method to update series datasource as shown here:

Code: Select all

    private void Form1_Load(object sender, EventArgs e)
    {
      // TODO: This line of code loads data into the 'dataSet1.Employee' table. You can move, or remove it, as needed.
      this.employeeTableAdapter.Fill(this.dataSet1.Employee);
      bar1.CheckDataSource();
    }

Visual Studio 2005 and DataBinding WAS ADO.NET Database

Posted: Fri May 26, 2006 2:53 pm
by 9640386
Hi Narcis,

I'm lost as to where I should add that code snippet. Looking at the code view for my Form1.vb, I see the following..

Code: Select all


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Grassland_weather_2005DataSet.grassland_weather_2005' table. You can move, or remove it, as needed.
        Me.Grassland_weather_2005TableAdapter.Fill(Me.Grassland_weather_2005DataSet.grassland_weather_2005)

    End Sub

Should I replace this Sub?

cheers, Paul

Posted: Fri May 26, 2006 2:58 pm
by narcis
Hi Paul,

No, you should just add a CheckDataSource call for each databinded series at the end of this sub. It should be something like this:

Code: Select all

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
        'TODO: This line of code loads data into the 'Grassland_weather_2005DataSet.grassland_weather_2005' table. You can move, or remove it, as needed. 
        Me.Grassland_weather_2005TableAdapter.Fill(Me.Grassland_weather_2005DataSet.grassland_weather_2005) 

        For i = 0 To TChart1.Series.Count - 1
            TChart1(i).CheckDataSource()
        Next
    End Sub 

Posted: Fri May 26, 2006 3:18 pm
by 9640386
Hi Narcis,

I've tried the snippet with the For Loop and the following version (both produce the same result)..

Code: Select all

Public Class Form1

    Private Sub Grassland_weather_2005BindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Grassland_weather_2005BindingNavigatorSaveItem.Click
        Me.Validate()
        Me.Grassland_weather_2005BindingSource.EndEdit()
        Me.Grassland_weather_2005TableAdapter.Update(Me.Grassland_weather_2005DataSet.grassland_weather_2005)

    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Grassland_weather_2005DataSet.grassland_weather_2005' table. You can move, or remove it, as needed.
        Me.Grassland_weather_2005TableAdapter.Fill(Me.Grassland_weather_2005DataSet.grassland_weather_2005)
        TChart1(0).CheckDataSource()

    End Sub

End Class
Neither makes any difference. When I hit F5 to test the chart I get a empty TChart on the form.

Here is the Debug output..

Code: Select all


'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\weather_charting\weather_charting\bin\Debug\weather_charting.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Design\2.0.0.0__b03f5f7f11d50a3a\System.Design.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic\8.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0x98c has exited with code 0 (0x0).
'weather_charting.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\weather_charting\weather_charting\bin\Debug\weather_charting.exe', Symbols loaded.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll', No symbols loaded.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\weather_charting\weather_charting\bin\Debug\TeeChart.dll', No symbols loaded.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.Transactions\2.0.0.0__b77a5c561934e089\System.Transactions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'weather_charting.vshost.exe' (Managed): Loaded 'C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.Wrapper.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 0xd14 has exited with code 0 (0x0).
The thread 0xe58 has exited with code 0 (0x0).
The program '[780] weather_charting.vshost.exe: Managed' has exited with code 0 (0x0).

I have the same problem using TChart with data from a CSV file. The chart looks great in the Design View, but no data is displayed when I build the application. Is there any other information which might help you diagnose this problem?

Paul

Posted: Fri May 26, 2006 3:29 pm
by narcis
Hi Paul,

It's very difficult to guess without being able to reproduce the problem here. Would you be so kind to arrange a simple project we can run "as-is" to reproduce the problem here? For example, you can use the database at C:\Program Files\Steema Software\TeeChart for .NET v2\Sample data\TeeChart.mdb for this example.

You can post your files at news://www.steema.net/steema.public.attachments newsgroup.

VS 2005, TChart.NET and Database connectivity

Posted: Fri May 26, 2006 5:14 pm
by 9640386
Hi Narcis,

I tried to post the files to you news server, but I'm getting a message too large error from the server. The attachment is about 1 MB. I'm putting it on a webpage, so you can download it from there if you like.

http://mprlsrvr1.bio.nau.edu/db_test_2.zip

When I first tried to include the TeeChart.mdb database, I could not find it in the C:\Program Files\Steema Software\TeeChart for .NET v2\Sample data folder. I removed the Steema software and re-installed the full version of TeeChart for .NET from the customer download site. I did not re-install the debug version, since using it diid not seem to make any difference in the error.

Also, I have been getting the following error from Visual Studio while trying to use TeeChart for .NET...

Code: Select all

Type 'System.Data.DataColumn' in Assembly 'System.Data, Version=2.0.0.0, Culture=neutral, PublicKey Token=b77a5c561934e089' is not marked as serialzable.
Let me know if you require any additional information.

cheers, Paul

Posted: Mon May 29, 2006 8:49 am
by narcis
Hi Paul,

Thanks for the example project. Your project works fine on my machine and doesn't work if I comment out the CheckDataSource call. Can you please check it again at your end and get back to use whith the results?

Thanks in advance.

Posted: Tue May 30, 2006 3:20 pm
by 9640386
Hello Narcis,

I just tried the test_db_2 project again and it still does not work. I also built another version, following the same steps. It built with the following errors..

Code: Select all


------ Build started: Project: db_test_2, Configuration: Debug Any CPU ------
C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\bin\LC.exe /target:db_test_2.exe /complist:"My Project\licenses.licx" /outdir:obj\Debug\ /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll /i:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /i:..\..\..\Controls\Steema\TeeChart.dll 
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Vbc.exe /noconfig /imports:Microsoft.VisualBasic,System,System.Collections,System.Collections.Generic,System.Data,System.Drawing,System.Diagnostics,System.Windows.Forms /nowarn:42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 /rootnamespace:db_test_2 /doc:obj\Debug\db_test_2.xml /define:"CONFIG=\"Debug\",DEBUG=-1,TRACE=-1,_MyType=\"WindowsForms\",PLATFORM=\"AnyCPU\"" /reference:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Data.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Deployment.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Design.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Drawing.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Web.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Windows.Forms.dll,C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll,..\..\..\Controls\Steema\TeeChart.dll /main:db_test_2.My.MyApplication /debug+ /debug:full /out:obj\Debug\db_test_2.exe /resource:obj\Debug\db_test_2.Form1.resources /resource:obj\Debug\db_test_2.Resources.resources /resource:obj\Debug\db_test_2.exe.licenses /target:winexe Form1.vb Form1.Designer.vb "My Project\AssemblyInfo.vb" "My Project\Application.Designer.vb" "My Project\Resources.Designer.vb" "My Project\Settings.Designer.vb" TeeChartDataSet.Designer.vb
C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\db_test_2\db_test_2\Form1.vb(5) : error BC30456: 'OrdersBindingSource' is not a member of 'db_test_2.Form1'.
C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\db_test_2\db_test_2\Form1.vb(6) : error BC30456: 'OrdersTableAdapter' is not a member of 'db_test_2.Form1'.
C:\Documents and Settings\plh26\My Documents\Visual Studio 2005\Projects\db_test_2\db_test_2\Form1.vb(14) : error BC30456: 'OrdersTableAdapter' is not a member of 'db_test_2.Form1'.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
Additionally, I am still getting the same "System.Data.DatColumn' error mentioned in my previous message. If I create a project with just the DataBinding Source and a DataGridView, it builds just fine and the resulting application displays the data properly. It seems to methat there is something wrong with the connection between my DataBindingSource and my TChart. Did you modify my project at all? Which version of TeeChart for .Net and Visual Studio 2005 are you using?

cheers, Paul

Posted: Wed May 31, 2006 8:30 am
by narcis
Hi Paul,

No, I didn't modify your project at all. Just tried commenting the CheckDataSource line so see if affected data being displayed and it did.
TeeChart version I used is the same as in your project, build 2.0.2179.21171. Also notice that this is not the latest version available. You could try upgrading it. Regarding Visual Studio .NET 2005, I'm using:

Microsoft Visual Studio 2005
Version 8.0.50727.42 (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Posted: Thu Jun 01, 2006 11:30 pm
by 9640386
Hello Narcis,

I removed and re-installed Visual Studio, .NET framework and TeeChart for .NET, but I still have the same problem. When I installed TeeChart, I saw a Toolbox.exe error, but the TeeChart tools did appear in the VS toolbox. I also ran the TeeRegV2 tool after the install. For TeeChart I used the latest TeeChartNET2VSNET2005.exe from your site. My version of Visual Studion and .NET are below:

Code: Select all

Microsoft Visual Studio 2005
Version 8.0.50727.42  (RTM.050727-4200)
Microsoft .NET Framework
Version 2.0.50727

Installed Edition: Professional

Microsoft Visual Basic 2005   77626-009-0000007-41446
Microsoft Visual Basic 2005

Microsoft Visual C# 2005   77626-009-0000007-41446
Microsoft Visual C# 2005

Microsoft Visual C++ 2005   77626-009-0000007-41446
Microsoft Visual C++ 2005

Microsoft Visual J# 2005   77626-009-0000007-41446
Microsoft Visual J# 2005

Microsoft Visual Web Developer 2005   77626-009-0000007-41446
Microsoft Visual Web Developer 2005

Crystal Reports    AAC60-G0CSA4B-V7000AY
Crystal Reports for Visual Studio 2005
Is there a way to check the version of TeeChart that is loaded on my machine? Also, can you send me a compiled .exe of the project (db_test.2) I put on the web for you. Seeing whether it runs on my workstation might tell us something about what is wrong here.

cheers, Paul[/code]