Solved

How to populate axspreadsheet from SQL Server db

Posted on 2011-02-23
4
658 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

624 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