Jump to content

Recommended Posts

Posted

boas tou a fazer uma aplicaçao que ira buscar a informaçao a um xls e quero que me passe essa informaçao para SQL.

Ate agora ja a consegui mostrar numa datagrid como faço para passar essa informaçao para o sql???

Posted

Tenta usar a ferramenta de importação do Sql Management Studio

Oracle Certified Professional - AdministraçãoOracle Certified Professional - Pl/sqlMCPD - Microsoft Certified Professional DeveloperMCTS - Microsoft Certified Technology Specialist

Posted

eu a maneira que tou a fazer tou a ir buscar o excel e a depositar para uma datagridview e eu queria enviar directamente para uma tabela no sql

Dim da As New OleDbDataAdapter
Dim dt As New DataTable
' cria um novo dataadapter
Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" & OpenFileDialog1.FileName & ";Extended Properties=Excel 8.0;"
' preenche a tabela com dados do Excel
dt =
New DataTable
da = New OleDbDataAdapter("SELECT * FROM [Folha1$]", conexao_Excel)
da.Fill(dt)
' define a chave primaria
dt.PrimaryKey =
New DataColumn() {dt.Columns(0)}
' registros somente podem ser inseridos usando esta tecnica
dt.DefaultView.AllowDelete = False
dt.DefaultView.AllowEdit = False
dt.DefaultView.AllowNew = False
' vincula o modo de visao padrão da tabela ao datagrid
DataGridView1.DataSource = dt.DefaultView
Posted

eu csg fazer de outra forma mandei os campos para uma datagridview e depois da datagridview para o SQL alguem consegue arranjar me uma maneira direta???

Dim sqlcom1 As New SqlCommand
sqlcom1.Connection = con
Try
con.Open()
For m = 0 To DataGridView1.Rows.Count - 1
Dim qinsert As String
qinsert = "insert into artigos(socio, Artigo, Quantidade) values (@socio, @artigo, @quantidade)"
Dim insertcommand As New SqlCommand(qinsert, con)
insertcommand.Parameters.AddWithValue("@Socio", DataGridView1.Rows(m).Cells(0).Value)
insertcommand.Parameters.AddWithValue("@Artigo", DataGridView1.Rows(m).Cells(1).Value)
insertcommand.Parameters.AddWithValue("@Quantidade", DataGridView1.Rows(m).Cells(1).Value)
insertcommand.ExecuteNonQuery()
Next
con.Close()
MessageBox.Show("saved successfully", "Sales", MessageBoxButtons.OK, MessageBoxIcon.Information)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Posted

boas aqui no meu projecto eu tou a carregar os meus ficheiros xls para uma

checkedListBox

o que me esta a acontecer e que quando selecciono por exemplo um dos ficheiros ele nao me retorna o conteudo.

eu tou a carregar essa checkedlistbox atraves de um ini e queria seleccionar varios ficheiros e le los para dentro do sql, alquem me consegue tirar esta duvida aqui??

a minha conexao tou a usar da seguinte forma so que nao me liga

Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" '& CheckedListBox1.SelectedItem.ToString & ";Extended Properties=Excel 8.0;"

se usar de forma directa funciona

Dim conexao_Excel As String = "Provider=Microsoft.Jet.OleDb.4.0;data source=" & OpenFileDialog1.FileName & ";Extended Properties=Excel 8.0;"

alguem tem alguma ideia???

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.