Continuation question....

D

DC

Thank you very useful.

Just another quick question, Im now getting

" Compiler Error Message: CS1502: The best overloaded method match for
'System.Data.OleDb.OleDbCommand.OleDbCommand(string,
System.Data.OleDb.OleDbConnection)' has some invalid arguments"

When I run the following code

string strConnectionString, strQueryString;
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data
Source='C:\\Program Files\\Common Files\\ODBC\\Data
Sources\\seminars.mdb';";

DateTime dtAddSeminarDate = new DateTime();
dtAddSeminarDate = DateTime.Parse(tbSeminarDate.Text);

string AddSemSql = "INSERT INTO SeminarList (Speaker, SpeakerEmail,
SpeakerInstitution,"
+ "SeminarTitle, SeminarDate, SeminarTime, SeminarLocation,
SeminarDetails, SeminarHost,"
+ " SeminarHostEmail, SeminarType, OrganisationNotes)"
+ " VALUES (" + tbSpeaker.Text + "," + tbSpeakerEmail.Text + "," +
tbSpeakerInstitution.Text +","
+ tbSeminarTitle.Text + "," + dtAddSeminarDate + "," +
tbSeminarTime.Text + "," + tbSeminarLocation.Text + ","
+ tbSeminarDetails.Text + "," + tbSeminarHost.Text + "," +
tbSeminarHostEmail.Text + "," + tbSeminarType.Text + "," +
tbOrganisationNotes.Text +")";

OleDbCommand cmd = new OleDbCommand(AddSemSql, strConnectionString);

Any ideas?


--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
 
D

DC

Cheers I replaced it with

OleDbConnection Conn = new OleDbConnection(strConnectionString);

OleDbCommand cmd = new OleDbCommand(AddSemSql, Conn);

and its working fine now. Think Ive gone a bit codeblind :)
You need to pass an actual connection object in, not a connection string.

--
_______________________________________________

DC

"You can not reason a man out of a position he did not reach through reason"

"Don't use a big word where a diminutive one will suffice."

"A man with a watch knows what time it is. A man with two watches is
never sure." Segal's Law
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top