programadorvb6 Posted November 22, 2019 at 06:22 PM Report Share #616682 Posted November 22, 2019 at 06:22 PM Olá boa noite. Estou com um problema em criar via código VB.Net uma base de dados que contenha uma chave primaria e mais 5 campos fiz assim o código mas não consegui criar a base de dados. Grato desde já pela vossa atenção. Imports System.Data.OleDb Imports System.Text Public Class Form1 Public Ligacao As New OleDbConnection Public SQL As StringBuilder Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Ligacao.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & My.Application.Info.DirectoryPath & "\Viaturas.mdb" SQL = New StringBuilder SQL.Append("CREATE TABLE Viaturas [Matriculas] NCHAR (15) NOT NULL PRIMARYKEY, [Nome] NCHAR (25) NOT NULL,[Empresa] NCHAR (20) NOT NULL,[Piso] NCHAR (6) NOT NULL ,[Ext] NCHAR (6) NOT NULL") Executar1(SQL.ToString) End Sub Public Sub Executar1(ByVal pSQL As String) Dim Comando As OleDbCommand = Ligacao.CreateCommand Try Comando.CommandText = pSQL Comando.CommandType = CommandType.Text Comando.ExecuteNonQuery() Catch ex As Exception If Err.Number = 5 AndAlso Err.Number = 5 Then MessageBox.Show(ex.Message) Else MessageBox.Show("Erro descrição : " & vbCrLf & ex.Message & vbCrLf, "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Error) End If End Try End Sub End Class ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé. Link to comment Share on other sites More sharing options...
brunotoira Posted November 22, 2019 at 06:26 PM Report Share #616683 Posted November 22, 2019 at 06:26 PM Qual é o erro que te dá? Source code para enviar UBL - Faturação Eletrónica (XML de faturas e validador) - bmartins.p45@gmail.com QRCode ATCUD https://www.portugal-a-programar.pt/forums/topic/77364-at-questões-legais/?do=findComment&comment=619124 Source ATCUD (Séries) https://www.portugal-a-programar.pt/forums/topic/57734-utilizar-webservices-da-at/?do=findComment&comment=627736 Link to comment Share on other sites More sharing options...
programadorvb6 Posted November 22, 2019 at 10:27 PM Author Report Share #616686 Posted November 22, 2019 at 10:27 PM Olá Obrigado por ter respondido o erro é este. https://imgbox.com/gallery/edit/buyM7bToFN/ylgtpqXtGlQyt06R ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé. Link to comment Share on other sites More sharing options...
programadorvb6 Posted November 24, 2019 at 10:49 AM Author Report Share #616694 Posted November 24, 2019 at 10:49 AM (edited) Resolvido! Obrigado desde já pela vossa ajuda. Edited November 24, 2019 at 10:49 AM by programadorvb6 ______________________________________________________________________________ Que minha coragem seja maior que meu medo e que minha força seja tão grande quanto minha fé. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now