Bom , colegas, abaixo tenho o código principal do meu projeto mas nao sei como modifica-lo para se adaptar ao ambiente
ACCESS- Net Framework 2.0 e Windows Application C#
Acontece uma exception(The ConnectionString property has not been initialized.)
na hora de execucao (qdo aperto F5, o debug nao localiza nenhum erro): apontando p/ a parte em azul.
Agradeco desde já!
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient; //? ou using System.Data.oledb;
namespace waTr325
{
public partial class frm325:Form
{
public frmABC()
{
InitializeComponent();
}
private DataSet ds;
private SqlDataAdapter da;
private void frm325_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'bdDocTed2DataSet.tbl325' table.
//You can move, or remove it, as needed.
this.tbl325TableAdapter.Fill(this.bdDocTed2DataSet.tbl325);
// TODO: This line of code loads data into the 'bdDocTed2DataSet.tbl325' table.
//You can move, or remove it, as needed.
this.tbl325TableAdapter.Fill(this.bdDocTed2DataSet.tbl325);
// conexão com o banco ACCESS ??.
SqlConnection conn = new SqlConnection("C:\Documents and Settings\Administrador\Meus documentos\Tr325\waTr325\waTr325\bdDocTed2.mdb;");
// dataadapter para fazer a pesquisa-> qual dos dois???? tbl325 = nome da tabela
da = new SqlDataAdapter("Select * From tbl325", conn);
//da = new SqlDataAdapter(SqlDataAdapter.DefaultSourceTableName,conn);
// CommandBuilder
SqlCommandBuilder cb = new SqlCommandBuilder(da);
// Então executamos o método Fill para obtermos os dados...
ds = new DataSet();
da.Fill(ds , "tbl325.mdb");
// vincular os dados obtidos ao DataGrid.
dGrid325.DataSource = ds.Tables["tbl325.mdb"];
try
{
da.Update(ds, "tbl325");
}
catch (SqlException ex)
{
// Vou mostrar a mensagem de erro completa para o usuário
string erros = ex.Message + Environment.NewLine;
foreach (SqlError err in ex.Errors)
{
// Só para não duplicar a mensagem de erro...
if (err.Message != ex.Message)
erros += err.Message;
}
erros = "Um erro ocorreu ao tentar salvar os dados : " + Environment.NewLine + erros;
MessageBox.Show(erros, "Exemplo", MessageBoxButtons.OK);
}
}
private void btnAtualizar_Click(object sender, EventArgs e)
{
tbl325TableAdapter.Update(bdDocTed2DataSet.tbl325);
}
}
}