Solved

How to populate axspreadsheet from SQL Server db

Posted on 2011-02-23
4
649 Views
Last Modified: 2012-05-11
Hi, can enyone provide me with the code how can I populate my axspreadsheet with data from SQL Server database...
I tried with the code below but it does not work
"Unable to cast object of type 'System.Windows.Forms.BindingSource' to type 'msdatasrc.DataSource'."

Please help...
I would apprecate a lot...
Private Sub GetData(ByVal selectCommand As String)

        Try
            
            Dim connectionString As String = My.Settings.ControllingConnectionString

            Me.dataAdapter = New SqlDataAdapter(selectCommand, connectionString)

            Dim commandBuilder As New SqlCommandBuilder(Me.dataAdapter)

            table.Locale = System.Globalization.CultureInfo.InvariantCulture
            Me.dataAdapter.Fill(table)
            Me.AxSpreadsheet1.DataSource = table


        Catch ex As SqlException
            MessageBox.Show("NOK")
        End Try

    End Sub

Open in new window

0
Comment
Question by:alsam
  • 2
4 Comments
 
LVL 9

Expert Comment

by:suvmitra
ID: 34970725
you must specify a connection in your code ..which is missing.

            Dim connectionString As String = "Data Source=localhost;Initial Catalog=DatabaseName;User Id=sa;Password=pass"
0
 
LVL 1

Author Comment

by:alsam
ID: 34973510
It is specified in My.Settings.ControllingConnectionString
Its not a problem....
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 35021637
0
 
LVL 1

Author Closing Comment

by:alsam
ID: 35021730
Right
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
vb.net help 4 34
vb.net winforms sizing/resolution? 4 46
How do sunrise and sunset times change with altitude 14 38
Help with preventing selection from a combobox 11 35
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question