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

推荐订阅源

小众软件
小众软件
B
Blog RSS Feed
美团技术团队
博客园 - 【当耐特】
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
M
MIT News - Artificial intelligence
aimingoo的专栏
aimingoo的专栏
J
Java Code Geeks
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
博客园 - 司徒正美
T
Tailwind CSS Blog
Last Week in AI
Last Week in AI
Google DeepMind News
Google DeepMind News
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
N
Netflix TechBlog - Medium
Vercel News
Vercel News
P
Proofpoint News Feed
IT之家
IT之家
I
InfoQ
腾讯CDC
H
Hackread – Cybersecurity News, Data Breaches, AI and More

博客园 - 七月的火热

浅谈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