Solved

How to populate axspreadsheet from SQL Server db

Posted on 2011-02-23
4
643 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
Comment Utility
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
Comment Utility
It is specified in My.Settings.ControllingConnectionString
Its not a problem....
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
Comment Utility
0
 
LVL 1

Author Closing Comment

by:alsam
Comment Utility
Right
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now