import-bot (20211) [Avatar] Offline
#1
[Originally posted by olivboy]

In Chapter 10, section 10.2 COMMANDTEXT AND COMMANDTYPE there is this portion
of code:
SqlCommand comm = new SqlCommand(conn);
comm.CommandType = CommandType.Text;
comm.CommandText = "Update Teachers Set ClassRoom=’G2’ " +
" WHERE TeacherID=2";

The problem is that i didnt find a constructor for SqlCommand class wich takes
a connection object as a parameter.
So, whats the catch ?
import-bot (20211) [Avatar] Offline
#2
Re: SqlCommand - unavailable constructor
[Originally posted by arlen]

Oops - sorry - both for the long time in replying and in the mistake in the
code snippet.

Try this:

SqlCommand comm = new SqlCommand("",conn);

or

SqlCommand comm = new SqlCommand();
comm.Connection = conn;

Arlen


> In Chapter 10, section 10.2 COMMANDTEXT AND COMMANDTYPE there is this portion
> of code:
> SqlCommand comm = new SqlCommand(conn);
> comm.CommandType = CommandType.Text;
> comm.CommandText = "Update Teachers Set ClassRoom=’G2’ " +
> " WHERE TeacherID=2";
>
> The problem is that i didnt find a constructor for SqlCommand class wich takes
> a connection object as a parameter.
> So, whats the catch ?
import-bot (20211) [Avatar] Offline
#3
Re: SqlCommand - unavailable constructor
[Originally posted by olivboy]

Ok, thank you Arlen !