Dim connStr, cmdStr As String Try connStr="connection string works" cmdStr = "SELECT * FROM [Table1];" Using conn As New SqlConnection(connStr) Using cmd As New SqlCommand(cmdStr, conn) conn.Open() Using myreader = cmd.ExecuteReader() If myreader.Read() Then For Each k In columns 'How do you find # of columns Next End If End Using conn.Close() cmd.Dispose() conn.Dispose() End Using End Using Catch ex As Exception TextBox6.Text = "Username: " & ex.ToString() End Try
SELECT COUNT(COLUMN_NAME) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TableName'
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)