Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

iz txtBox u access bazu

[es] :: .NET :: iz txtBox u access bazu

[ Pregleda: 2984 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

kristian!

Član broj: 8348
Poruke: 150
*.dialup.neobee.net.

Sajt: www.linkoovi.net


+1 Profil

icon iz txtBox u access bazu16.08.2004. u 17:31 - pre 239 meseci
problem:
Code:
private void button1_Click(object sender, System.EventArgs e){
            

string accessPath = Application.StartupPath.ToString() + "/test.mdb";

string connectionString = "provider=Microsoft.JET.OLEDB.4.0; " + "data source ="
+ accessPath + "; Integrated Security=SSPI;";

string commandString = "INSERT INTO tabelaTest VALUES ('" + txtBoxBla.Text + "')";
OleDbConnection AccessDbConnection = new OleDbConnection(connectionString);
            OleDbCommand AccessOleCommand = new OleDbCommand(commandString);
            AccessDbConnection.Open();
            AccessOleCommand.ExecuteNonQuery();
            AccessDbConnection.Close();
            
           
}


kada stisnem button1_Click dobilem dijalog:

Multiple-setup OLE DB operation generated erros. Check Each OLE DB Stats value, if available. No eork was done.

ako is connectionString izvrisem Integrated Security=SSPI; onda dobijem ovo:

ExecuteNonQuery: Connection property has not been initialized.

Gde gresim?
 
Odgovor na temu

havramm
Miroslav Havram
Software Developer / Engineer
Beograd

Član broj: 4603
Poruke: 255
212.62.55.*



Profil

icon Re: iz txtBox u access bazu16.08.2004. u 21:41 - pre 239 meseci
Citat:
kristian!: ... Integrated Security=SSPI; ...

Ovo ti ovde ne treba. Koristi se samo kod konekcije na SQL server. Zato ti javlja onu prvu gresku (probaj da vidis sta se desava ako izostavis Integrated Security... ).

Sto se tice druge greske, sledeci kod
Code:
OleDbCommand AccessOleCommand = new OleDbCommand(commandString);

izmedju ostalog postavalja property Connection objekta OleDbCommand na null, tako da komanda nezna koju konekciju da koristi da bi se "nakacila" na bazu. Upotrebi sledece:
Code:
OleDbCommand AccessOleCommand = new OleDbCommand(commandString, AccessDbConnection);

ili
Code:
OleDbCommand AccessOleCommand = new OleDbCommand(commandString);
AccessOleCommand.Connection = AccessDbConnection;

i trebalo bi da radi!
If it's a girl then they're gonna call it Sigourney, after an actress. If it's a boy, then they're gonna call it Rodney, after Dave!
 
Odgovor na temu

esnaf

Član broj: 9417
Poruke: 43
*.fiberop.matgnet.com



Profil

icon Re: iz txtBox u access bazu17.08.2004. u 08:49 - pre 239 meseci
Drugo resenje je da napravis .udl fajl i da ga referenciras is aplikacije
Jedini problem kod ovog je sto pri migraciji aplikacije moras da promenis putanju do .udl fajla

Code:

string connstring=@"File Name=C:\....\baza.udl";

 
Odgovor na temu

[es] :: .NET :: iz txtBox u access bazu

[ Pregleda: 2984 | Odgovora: 2 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.