susie Posted January 6, 2010 at 03:28 PM Report Share #304481 Posted January 6, 2010 at 03:28 PM Sou principiante em vb.net. Estou a tentar inserir valores na BD em SQL server a query ta a funcionar correctamente, mas qd chamo o procedimento inserir, ele gera me uma excepçao coloquei a em comentario, a string de conexao tou a recebe-la de um ficheiro xml. Ponho aqui o codigo a primeira liga me a bd a segunda e entao o inserir Public Overloads Function Conexao() As DataSet 'strConexao = "server=NEWPOS2\SSILVA;Trusted_Connection=yes;database=estagio" Dim objConexao As New SqlConnection(strConexao) Try objConexao.Open() Catch ex As Exception MsgBox(ex.Message) End Try MessageBox.Show("acesso à base de dados!") End Function ' Conexao_bd Public Function inserir(str As String) ' strConexao = "server=NEWPOS2\SSILVA;Trusted_Connection=yes;database=estagio" Dim objConexao As New SqlConnection(strConexao) Dim ins As New SqlCommand(str, objConexao) 'Dim val As Integer objConexao.Open() Try ' ins.EndExecuteNonQuery(str) ins.ExecuteNonQuery() Catch ex As Exception ' Incorrect syntax near ')'. Unclosed quotation mark after the character string ' ' MsgBox(ex.Message) End Try MsgBox("dados inseridos") Return str End Function desde ja agradeço a ajuda Link to comment Share on other sites More sharing options...
jpaulino Posted January 6, 2010 at 03:35 PM Report Share #304485 Posted January 6, 2010 at 03:35 PM Lê estes artigo para iniciar: VB.NET: Gestão de Dados em SQL Server - Parte I VB.NET: Gestão de Dados em SQL Server - Parte II Link to comment Share on other sites More sharing options...
susie Posted January 6, 2010 at 04:28 PM Author Report Share #304502 Posted January 6, 2010 at 04:28 PM oki bigada vou ver entao 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