DATAGRID NAO EXIBE OS DADOS
Usei esse código para acessar o SQLServer diretamento no pocket, mas o data grid não exibe os dados existentes nas tabelas!
Dim connString As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = 1234", myConnection)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "wsHistFaturas")
DataGrid1.DataSource = ds.DefaultViewManager
Dim connString As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = 1234", myConnection)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "wsHistFaturas")
DataGrid1.DataSource = ds.DefaultViewManager
Chaapolinn, usei mas ainda não está funcionando!
Obrigado!
Obrigado!
Dim connString As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
' create a data adapter
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = 1234", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet()
' fill dataset
da.Fill(ds, "wsHistFaturas")
' write dataset contents to an xml file by calling WriteXml method
' Attach DataSet to DataGrid
DataGrid1.DataSource = ds.Tables("WsHistFaturas")
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
' create a data adapter
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = 1234", myConnection)
' create a new dataset
Dim ds As DataSet = New DataSet()
' fill dataset
da.Fill(ds, "wsHistFaturas")
' write dataset contents to an xml file by calling WriteXml method
' Attach DataSet to DataGrid
DataGrid1.DataSource = ds.Tables("WsHistFaturas")
AÃ está ele, funcionando!
Tenho outro problema agora! Tenho um Combobox que exibe os nomes dos clientes, e no datagrid exibo as faturas dos clientes, mas nessa tabela das faturas guardo apenas o código do cliente, como eu faço pra mostrar no datagrid apenas as faturas com código do cliente referente ao nome que esta no combobox
Uso esse fonte para encher o combobox:
Dim strCn As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim Cn As System.Data.SqlServerCe.SqlCeConnection = New System.Data.SqlServerCe.SqlCeConnection(strCn)
Cn.Open()
Dim DSet As New Data.DataSet(), SQLStr As String
Dim comando As System.Data.SqlServerCe.SqlCeCommand
Dim Adaptr As System.Data.SqlServerCe.SqlCeDataAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter()
Dim tRow As Data.DataRow, tTbl As Data.DataTable 'cria o objeto datarow e datatable
'mapeia a tabela clientes , monta o sql para selecionar os nomes dos clientes
'e executa o objeto command preenchendo a seguir o dataset
With Adaptr
.TableMappings.Add("Table", "WsClientes")
SQLStr = "Select Nome, Cod from WsClientes order by Nome"
comando = New System.Data.SqlServerCe.SqlCeCommand(SQLStr, Cn)
.SelectCommand = comando
.Fill(DSet)
.Dispose()
End With
DSet.AcceptChanges()
tTbl = DSet.Tables.Item(0)
DSet.Dispose()
Cn.Close()
'preenche o combo combobox
ComboBox1.Text = ""
ComboBox1.Items.Clear()
ComboBox1.BeginUpdate()
'carrega o combo com o nome dos clientes
For Each tRow In tTbl.Rows
ComboBox1.Items.Add(tRow("Nome").ToString)
TextBox1.Text = "WsHistFaturas"
Next
ComboBox1.EndUpdate()
ComboBox1.ValueMember = "Cod"
ComboBox1.Text = "nome"
Uso esse fonte para encher o combobox:
Dim strCn As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim Cn As System.Data.SqlServerCe.SqlCeConnection = New System.Data.SqlServerCe.SqlCeConnection(strCn)
Cn.Open()
Dim DSet As New Data.DataSet(), SQLStr As String
Dim comando As System.Data.SqlServerCe.SqlCeCommand
Dim Adaptr As System.Data.SqlServerCe.SqlCeDataAdapter = New System.Data.SqlServerCe.SqlCeDataAdapter()
Dim tRow As Data.DataRow, tTbl As Data.DataTable 'cria o objeto datarow e datatable
'mapeia a tabela clientes , monta o sql para selecionar os nomes dos clientes
'e executa o objeto command preenchendo a seguir o dataset
With Adaptr
.TableMappings.Add("Table", "WsClientes")
SQLStr = "Select Nome, Cod from WsClientes order by Nome"
comando = New System.Data.SqlServerCe.SqlCeCommand(SQLStr, Cn)
.SelectCommand = comando
.Fill(DSet)
.Dispose()
End With
DSet.AcceptChanges()
tTbl = DSet.Tables.Item(0)
DSet.Dispose()
Cn.Close()
'preenche o combo combobox
ComboBox1.Text = ""
ComboBox1.Items.Clear()
ComboBox1.BeginUpdate()
'carrega o combo com o nome dos clientes
For Each tRow In tTbl.Rows
ComboBox1.Items.Add(tRow("Nome").ToString)
TextBox1.Text = "WsHistFaturas"
Next
ComboBox1.EndUpdate()
ComboBox1.ValueMember = "Cod"
ComboBox1.Text = "nome"
voce pode codificar no evento SelectedIndexChanged do combo para pegar o selectedvalue e ai selecionar as faturas do cliente selecionado
Obrigado amigos, está sendo de grande ajuda!
Aki carrego o combo e atribuo os valores Displeymember e Valuemember
For Each tRow In tTbl.Rows
ComboBox1.Items.Add(tRow("Nome").ToString)
Next
ComboBox1.EndUpdate()
ComboBox1.DisplayMember = "Nome"
ComboBox1.ValueMember = "Cod"
E aki tento carregar o datagrid, se no lubar do valor do combo na Sql eu colocar o codigo do cliente ele mostra, mas pelo combo não!
Dim connString As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = '" + ComboBox1.ValueMember + "'", myConnection)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "wsHistFaturas")
DataGrid1.DataSource = ds.Tables("WsHistFaturas")
Aki carrego o combo e atribuo os valores Displeymember e Valuemember
For Each tRow In tTbl.Rows
ComboBox1.Items.Add(tRow("Nome").ToString)
Next
ComboBox1.EndUpdate()
ComboBox1.DisplayMember = "Nome"
ComboBox1.ValueMember = "Cod"
E aki tento carregar o datagrid, se no lubar do valor do combo na Sql eu colocar o codigo do cliente ele mostra, mas pelo combo não!
Dim connString As String = "DataSource = \AFV\BdAFV\SoccolBd.sdf"
Dim myConnection As SqlCeConnection = New SqlCeConnection()
myConnection.ConnectionString = connString
Dim da As SqlCeDataAdapter = New SqlCeDataAdapter("Select Cod, Valor, Vcto, NumParcelas, DataBaixa from wsHistFaturas WHERE Cliente = '" + ComboBox1.ValueMember + "'", myConnection)
Dim ds As DataSet = New DataSet()
da.Fill(ds, "wsHistFaturas")
DataGrid1.DataSource = ds.Tables("WsHistFaturas")
Tópico encerrado , respostas não são mais permitidas