We help IT Professionals succeed at work.
Get Started

Create a grid mixing Excel and SQL Table

544 Views
Last Modified: 2012-06-27
Hi!
            Thank you For reading my problem. I use this code To create a grid With a Excel file.

Dim MyConnExcel = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ExcelFile & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2""")
If MyConnExcel.State = ConnectionState.Closed Then MyConnExcel.Open()
Dim MyCommExcel As OleDbCommand = New OleDbCommand("SELECT SERVERS FROM [Sheet1$]", MyConnExcel)
da = New OleDbDataAdapter(MyCommExcel)
ds = New DataSet()
da.Fill(ds)

grvExcelData.DataSource = ds.Tables(0)
grvExcelData.DataBind()
grvExcelData.Visible = True

da.Dispose()
MyConnExcel.Close()
MyConnExcel.Dispose()

Open in new window

And I use this other code To create a grid from a SQL table
Dim MyConnSQL = New SqlConnection(strConexionBHInv)
If MyConnSQL.State = ConnectionState.Closed Then MyConnSQL.Open()
Dim MyCommSQL As SqlCommand = New SqlCommand("SELECT SERVERS FROM MYSERVERS", MyConnSQL)
da = New SqlDataAdapter(MyCommSQL)
ds = New DataSet()
da.Fill(ds)

grvGridData.DataSource = ds.Tables(0)
grvGridData.DataBind()
grvGridData.Visible = True

da.Dispose()
MyConnSQL.Close()
MyConnSQL.Dispose()

Open in new window

The question Is:
          how I can create a unique grid matching "server" column (programatically)?
          If I don't explain well something like this
 
        
ExcelSheet
==========

SERVERS			IP
sql_srv		192.168.1.1
exchange_srv	192.168.1.2
dc_srv		192.168.1.3


SQL Table:
=========
SERVERS		DOMAIN
sql_srv		MELODY
exchange_srv	MELODY
dc_srv          CUSTOMY




THE GRID THAT I WANT!!!
          
SERVERS		IP			DOMAIN
sql_srv		192.168.1.1		MELODY
exchange_srv	192.168.1.2		MELODY
dc_srv         192.168.1.3		CUSTOMY

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 20 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE