Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Won't generate update/delete statements for fox tables
Message
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Divers
Thread ID:
00635807
Message ID:
00636128
Vues:
22
Here's a snippet of code that I was using when I was playing around with the DataAdapter:
		private SqlDataAdapter setupDataAdapter() 
		{
			SqlCommand cmd;
			SqlParameter p;
			
			SqlDataAdapter da = new SqlDataAdapter();
			SqlConnection cn = new SqlConnection(this.connectionString);
			da.SelectCommand = new SqlCommand("getEmployees", cn);
			da.SelectCommand.CommandType = CommandType.StoredProcedure;

			////////////////////////
			// setup Insert command
			////////////////////////
			cmd = new SqlCommand("addEmployee", cn);
			cmd.CommandType = CommandType.StoredProcedure;
			
			p = new SqlParameter("@emp_id", SqlDbType.Char, 9);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "emp_id";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@fname", SqlDbType.VarChar, 20);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "fname";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@minit", SqlDbType.Char, 1);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "minit";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@lname", SqlDbType.VarChar, 30);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "lname";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@job_id", SqlDbType.SmallInt);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "job_id";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@job_lvl", SqlDbType.TinyInt);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "job_lvl";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@pub_id", SqlDbType.Char, 4);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "pub_id";
			cmd.Parameters.Add(p);

			p = new SqlParameter("@hire_date", SqlDbType.DateTime);
			p.Direction = ParameterDirection.Input;
			p.SourceColumn = "hire_date";
			cmd.Parameters.Add(p);

			da.InsertCommand = cmd;
			// end setup Insert Command

			return da;
			
		}
I'm calling a proc but it should work the same with an explicit query. And this is using SQL Server.

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform