CRIAR BANCO, TABELA E SUAS CELULAS POR CODIGO
Então pessoal, estou usando o seguinte código:
tem coisa sobrando, eu sei...
Imports ADOX
Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Odbc.OdbcConnection
Imports System.Data.Odbc
Public Class criarbd
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = txtsala.Text
CreateDatabase(Caminho:=a + [Ô].mdb[Ô])
End Sub
Public Function CreateDatabase(ByVal Caminho As String) As Boolean
Dim oCatalog As New ADOX.Catalog
Try
oCatalog.Create([Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho)
CreateDatabase = Err.Number = 0
Dim con As Odbc.OdbcConnection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
tbl = New ADOX.Table
tbl.Name = [Ô]b1[Ô]
tbl.Columns.Append([Ô]Numero[Ô], DataTypeEnum.adVarChar, 40)
tbl.Columns.Append([Ô]nota[Ô], DataTypeEnum.adVarChar, 40)
tbl.Columns.Append([Ô]faltas[Ô], DataTypeEnum.adVarChar, 40)
cat.Tables.Append(tbl)
con = Nothing
tbl = Nothing
cat = Nothing
MessageBox.Show([Ô]Operação concluÃda[Ô], [Ô]ConcluÃdo[Ô])
Catch ex As Exception
MessageBox.Show([Ô]Não foi possÃvel completar essa operação[Ô], [Ô]Erro[Ô])
End Try
End Function
End Class
e ele está dando erro em cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
tem coisa sobrando, eu sei...
Imports ADOX
Imports System.Data.OleDb
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.Odbc.OdbcConnection
Imports System.Data.Odbc
Public Class criarbd
Dim a
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = txtsala.Text
CreateDatabase(Caminho:=a + [Ô].mdb[Ô])
End Sub
Public Function CreateDatabase(ByVal Caminho As String) As Boolean
Dim oCatalog As New ADOX.Catalog
Try
oCatalog.Create([Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho)
CreateDatabase = Err.Number = 0
Dim con As Odbc.OdbcConnection
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
tbl = New ADOX.Table
tbl.Name = [Ô]b1[Ô]
tbl.Columns.Append([Ô]Numero[Ô], DataTypeEnum.adVarChar, 40)
tbl.Columns.Append([Ô]nota[Ô], DataTypeEnum.adVarChar, 40)
tbl.Columns.Append([Ô]faltas[Ô], DataTypeEnum.adVarChar, 40)
cat.Tables.Append(tbl)
con = Nothing
tbl = Nothing
cat = Nothing
MessageBox.Show([Ô]Operação concluÃda[Ô], [Ô]ConcluÃdo[Ô])
Catch ex As Exception
MessageBox.Show([Ô]Não foi possÃvel completar essa operação[Ô], [Ô]Erro[Ô])
End Try
End Function
End Class
e ele está dando erro em cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
Porque vc está usando o ADO normal e não o ADO.NET? Ele substitui o ADOX com vantagens!
Teria como vc me mandar essa estrutura? to com problemas na conexão..
cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
cat.ActiveConnection = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] + a + [Ô].mdb[Ô]
putts cara, to tentando converter os codigo para vb.net mas ta tenso....usei até um conversor mas tem muita falha... fico assim:
[ô][ô]On Error Resume Next
Dim oCatalog As New ADOX.Catalog
[ô]Try
oCatalog.Create([Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho)
MessageBox.Show([Ô]passou Docat[Ô], [Ô]ConcluÃdo[Ô])
CreateDatabase = Err.Number = 0
MessageBox.Show([Ô]passou err[Ô], [Ô]ConcluÃdo[Ô])
Dim connectionString = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho
Dim connection As New SqlConnection(connectionString)
Dim server As New Server(New ServerConnection(connection))
[ô] Create table in my personal database
Dim db As Database = server.Databases([Ô]davidhayden[Ô])
[ô] Create new table, called TestTable
Dim newTable As New Table(db, [Ô]TestTable[Ô])
[ô] Add [Ô]ID[Ô] Column, which will be PK
Dim idColumn As New Column(newTable, [Ô]ID[Ô])
idColumn.DataType = DataType.Int
idColumn.Nullable = False
idColumn.Identity = True
idColumn.IdentitySeed = 1
idColumn.IdentityIncrement = 1
[ô] Add [Ô]Title[Ô] Column
Dim titleColumn As New Column(newTable, [Ô]Title[Ô])
titleColumn.DataType = DataType.VarChar(50)
titleColumn.Nullable = False
[ô] Add Columns to Table Object
newTable.Columns.Add(idColumn)
newTable.Columns.Add(titleColumn)
[ô] Create a PK Index for the table
Dim index As New Index(newTable, [Ô]PK_TestTable[Ô])
index.IndexKeyType = IndexKeyType.DriPrimaryKey
[ô] The PK index will consist of 1 column, [Ô]ID[Ô]
index.IndexedColumns.Add(New IndexedColumn(index, [Ô]ID[Ô]))
[ô] Add the new index to the table.
newTable.Indexes.Add(index)
[ô] Physically create the table in the database
newTable.C()
[ô][ô]On Error Resume Next
Dim oCatalog As New ADOX.Catalog
[ô]Try
oCatalog.Create([Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho)
MessageBox.Show([Ô]passou Docat[Ô], [Ô]ConcluÃdo[Ô])
CreateDatabase = Err.Number = 0
MessageBox.Show([Ô]passou err[Ô], [Ô]ConcluÃdo[Ô])
Dim connectionString = [Ô]Provider=Microsoft.Jet.OLEDB.4.0;Data Source=[Ô] & Caminho
Dim connection As New SqlConnection(connectionString)
Dim server As New Server(New ServerConnection(connection))
[ô] Create table in my personal database
Dim db As Database = server.Databases([Ô]davidhayden[Ô])
[ô] Create new table, called TestTable
Dim newTable As New Table(db, [Ô]TestTable[Ô])
[ô] Add [Ô]ID[Ô] Column, which will be PK
Dim idColumn As New Column(newTable, [Ô]ID[Ô])
idColumn.DataType = DataType.Int
idColumn.Nullable = False
idColumn.Identity = True
idColumn.IdentitySeed = 1
idColumn.IdentityIncrement = 1
[ô] Add [Ô]Title[Ô] Column
Dim titleColumn As New Column(newTable, [Ô]Title[Ô])
titleColumn.DataType = DataType.VarChar(50)
titleColumn.Nullable = False
[ô] Add Columns to Table Object
newTable.Columns.Add(idColumn)
newTable.Columns.Add(titleColumn)
[ô] Create a PK Index for the table
Dim index As New Index(newTable, [Ô]PK_TestTable[Ô])
index.IndexKeyType = IndexKeyType.DriPrimaryKey
[ô] The PK index will consist of 1 column, [Ô]ID[Ô]
index.IndexedColumns.Add(New IndexedColumn(index, [Ô]ID[Ô]))
[ô] Add the new index to the table.
newTable.Indexes.Add(index)
[ô] Physically create the table in the database
newTable.C()
Você chegou a olhar os links que te passei?
Sim, foi de lá que tirei os códigos em c# e passei p vb.net...
Tópico encerrado , respostas não são mais permitidas