惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
D
Docker
有赞技术团队
有赞技术团队
D
DataBreaches.Net
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
H
Help Net Security
美团技术团队
MyScale Blog
MyScale Blog
B
Blog RSS Feed
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
阮一峰的网络日志
阮一峰的网络日志
A
About on SuperTechFans
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
GbyAI
GbyAI
G
Google Developers Blog
月光博客
月光博客
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
F
Fortinet All Blogs

博客园 - 七月的火热

浅谈Excel 的VB编程 一组有用的操作Excel的函数 excel與vb.net的數據雙項操作,求高手幫忙! vb.net 操作excel - 七月的火热 - 博客园 VB.net,存EXCEL中的时间问题! VB.net调用Excel怎样设定列的列宽? 如何用VB.NET控制Excel單元格裡的內容 使用VB.NET编写控制excel的程序 ASP.NET中数据库数据导入Excel并打印 如何用VB.NET控制Excel單元格裡的內容? 经改良后的vb.net导出excel代码 wsdl和soap的关系 Microsoft Solutions Framework Version 3 White Papers C#设计模式(12)-Decorator Pattern C#设计模式(11)-Composite Pattern C#设计模式(10)-Adapter Pattern C#设计模式(9)-Prototype Pattern C#设计模式(8)-Builder Pattern C#设计模式(7)-Singleton Pattern
VB.net: 使用ODBC, ASP.net, VB.Net访问Excel文件
七月的火热 · 2006-11-09 · via 博客园 - 七月的火热
 

Private Sub Button1_Click(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles Button1.Click
        Me.OdbcConnection1.ConnectionString 
= ("DRIVER={MICROSOFT EXCEL DRIVER (*.XLS)};FIRSTROWHASNAMES=1;READONLY=FALSE;CREATE_DB=""C:Documents and Settingsykhu.xls"";DBQ=C:Documents and Settingsykhu.xls")
        Me.OdbcConnection1.Open()
        
If (OdbcConnection1.State = ConnectionState.Open) Then
            
'MsgBox("Connection setup.")
            Dim cmd As New System.Data.Odbc.OdbcCommand("select * from Test", Me.OdbcConnection1)
            
Dim rd As System.Data.Odbc.OdbcDataReader
            rd 
= cmd.ExecuteReader(CommandBehavior.Default)
            
Dim i As Int16
            Me.TextBox1.Text 
= ""
            For i = 0 To rd.FieldCount - 1
                Me.TextBox1.Text 
&= rd.GetName(i) & vbTab & vbTab
            
Next
            
While rd.Read()
                
For i = 0 To rd.FieldCount - 1
                    
Try
                        Me.TextBox1.Text 
&= rd.GetString(i)
                    
Catch ex As Exception
                        Me.TextBox1.Text 
&= Space(0)
                    
End Try
                    Me.TextBox1.Text 
= Me.TextBox1.Text & vbTab & vbTab
                
Next
                Me.TextBox1.Text 
= Me.TextBox1.Text & vbCrLf
            
End While
            OdbcConnection1.Close()
        
Else
            
MsgBox("Failed to open odbc")
        
End If
    
End Sub