Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: PlaceHolder, TreeView, UserControl Pin
Heath Stewart11-Jun-04 10:40
protectorHeath Stewart11-Jun-04 10:40 
Questioninefficient to create new delegate every time? Pin
vista2711-Jun-04 8:10
vista2711-Jun-04 8:10 
AnswerRe: inefficient to create new delegate every time? Pin
Heath Stewart11-Jun-04 8:48
protectorHeath Stewart11-Jun-04 8:48 
QuestionRichTextBox cannot handle huge amount of color-coded, varied font text? Pin
vista2711-Jun-04 7:47
vista2711-Jun-04 7:47 
AnswerRe: RichTextBox cannot handle huge amount of color-coded, varied font text? Pin
Aaron Eldreth11-Jun-04 8:32
Aaron Eldreth11-Jun-04 8:32 
GeneralRe: RichTextBox cannot handle huge amount of color-coded, varied font text? Pin
vista2711-Jun-04 9:16
vista2711-Jun-04 9:16 
GeneralRe: RichTextBox cannot handle huge amount of color-coded, varied font text? Pin
Aaron Eldreth11-Jun-04 12:18
Aaron Eldreth11-Jun-04 12:18 
GeneralUpdate to DB Failure Pin
MrJJKoolJ11-Jun-04 7:44
MrJJKoolJ11-Jun-04 7:44 
Hi,

I try to update Sql server DB with update from dataset but fails on the DataAdapter.Update with insert exception. here's my code :

<br />
<br />
try<br />
			{<br />
			<br />
				sSQLSel = @"SELECT * From MidnightReadings";<br />
				sSQLUpd = @"UPDATE MidnightReadings SET MR_Date = @MR_Date, Coal_Feeder_Tot = @Coal_Feeder_To" +<br />
					"t, Coal_Silo_Level_Prct = @Coal_Silo_Level_Prct, Coal_Barn_Inv_Prct = @Coal_Barn" +<br />
					"_Inv_Prct, Limestone_Feed_Total = @Limestone_Feed_Total, LS_Silo_Level_Prct = @L" +<br />
					"S_Silo_Level_Prct, Ammonia_Totalizer = @Ammonia_Totalizer, Prop_to_Burn_Totalize" +<br />
					"r = @Prop_to_Burn_Totalizer, TwentyFourHr_SO2_Reduct = @TwentyFourHr_SO2_Reduct," +<br />
					" Limestone_Received = @Limestone_Received, Ammonia_Received = @Ammonia_Received," +<br />
					" Prop_Received = @Prop_Received, Est_hours_Dry_Oper_Hours = @Est_hours_Dry_Oper_" +<br />
					"Hours, Est_hours_Dry_Oper_Mins = @Est_hours_Dry_Oper_Mins, LAB_Sulfur_Content_Pr" +<br />
					"ct = @LAB_Sulfur_Content_Prct, LAB_High_Heat_Val = @LAB_High_Heat_Val, CEMS_SO2_" +<br />
					"Daily_Avg = @CEMS_SO2_Daily_Avg, SO2_Daily = @SO2_Daily, Raw_Water_Pump_Meter = " +<br />
					"@Raw_Water_Pump_Meter, Reservoir_Level = @Reservoir_Level, Comments = @Comments," +<br />
					" Date_Rec_Added = @Date_Rec_Added WHERE (MR_Date = @MR_Date)";<br />
<br />
<br />
				SqlConnection myCon = new SqlConnection(sCon1);<br />
				<br />
				SqlDataAdapter da = new SqlDataAdapter(sSQLSel, myCon);<br />
<br />
				da.UpdateCommand = new SqlCommand(sSQLUpd, myCon);<br />
<br />
<br />
buildMNUpdParams(da.UpdateCommand);<br />
				da.Update(dsDiff,"MidnightReadings"); <- Fails here !<br />
				dsDiff.AcceptChanges();<br />
				myCon.Close();<br />
<br />
				return true;<br />
<br />
public static void buildMNUpdParams(SqlCommand workCommand)<br />
		{<br />
					<br />
<br />
			SqlParameter workParam = null;<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@MR_Date", SqlDbType.DateTime, 8));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "MR_Date";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Coal_Feeder_Tot", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Coal_Feeder_Tot";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Coal_Silo_Level_Prct", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Coal_Silo_Level_Prct";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Coal_Barn_Inv_Prct", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Coal_Barn_Inv_Prct";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Limestone_Feed_Total", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Limestone_Feed_Total";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@LS_Silo_Level_Prct", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "LS_Silo_Level_Prct";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Ammonia_Totalizer", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Ammonia_Totalizer";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Prop_to_Burn_Totalizer", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Prop_to_Burn_Totalizer";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@TwentyFourHr_SO2_Reduct", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "TwentyFourHr_SO2_Reduct";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Limestone_Received", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Limestone_Received";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Ammonia_Received", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Ammonia_Received";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Prop_Received", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Prop_Received";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Est_hours_Dry_Oper_Hours", SqlDbType.Int, 4));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Est_hours_Dry_Oper_Hours";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Est_hours_Dry_Oper_Mins", SqlDbType.Int, 4));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Est_hours_Dry_Oper_Mins";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@LAB_Sulfur_Content_Prct", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "LAB_Sulfur_Content_Prct";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@LAB_High_Heat_Val", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "LAB_High_Heat_Val";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@CEMS_SO2_Daily_Avg", SqlDbType.Int, 4));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "CEMS_SO2_Daily_Avg";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@SO2_Daily", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "SO2_Daily";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Raw_Water_Pump_Meter", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Raw_Water_Pump_Meter";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Reservoir_Level", SqlDbType.Decimal, 9));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Reservoir_Level";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Comments", SqlDbType.VarChar, 200));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Comments";<br />
			workParam = workCommand.Parameters.Add(new SqlParameter("@Date_Rec_Added", SqlDbType.DateTime, 8));<br />
			workParam.Direction = ParameterDirection.Input;<br />
			workParam.SourceColumn = "Date_Rec_Added";<br />
workParam = workCommand.Parameters.Add(new System.Data.SqlClient.SqlParameter("@MR_ID", System.Data.SqlDbType.BigInt, 8, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "MR_ID", System.Data.DataRowVersion.Original, null));<br />
		}<br />
<br />


Any ideas ?

Thanks,
JJ
GeneralRe: Update to DB Failure Pin
Colin Angus Mackay11-Jun-04 8:10
Colin Angus Mackay11-Jun-04 8:10 
GeneralRe: Update to DB Failure Pin
MrJJKoolJ11-Jun-04 8:33
MrJJKoolJ11-Jun-04 8:33 
GeneralRe: Update to DB Failure Pin
Heath Stewart11-Jun-04 8:49
protectorHeath Stewart11-Jun-04 8:49 
GeneralRe: Update to DB Failure Pin
MrJJKoolJ11-Jun-04 9:11
MrJJKoolJ11-Jun-04 9:11 
GeneralRe: Update to DB Failure Pin
Heath Stewart11-Jun-04 10:38
protectorHeath Stewart11-Jun-04 10:38 
GeneralRe: Update to DB Failure Pin
MrJJKoolJ11-Jun-04 11:26
MrJJKoolJ11-Jun-04 11:26 
GeneralRe: Update to DB Failure Pin
Heath Stewart11-Jun-04 11:52
protectorHeath Stewart11-Jun-04 11:52 
GeneralRe: Update to DB Failure Pin
MrJJKoolJ11-Jun-04 12:19
MrJJKoolJ11-Jun-04 12:19 
GeneralImport a comma delimited text file to a access database Pin
kornstyle11-Jun-04 7:31
kornstyle11-Jun-04 7:31 
GeneralRe: Import a comma delimited text file to a access database Pin
Heath Stewart11-Jun-04 8:30
protectorHeath Stewart11-Jun-04 8:30 
GeneralDataGridTextBoxColumn won't word wrap Pin
holt11-Jun-04 6:05
holt11-Jun-04 6:05 
GeneralRe: DataGridTextBoxColumn won't word wrap Pin
Heath Stewart11-Jun-04 6:27
protectorHeath Stewart11-Jun-04 6:27 
GeneralRe: DataGridTextBoxColumn won't word wrap Pin
holt11-Jun-04 7:14
holt11-Jun-04 7:14 
GeneralC++ pointer char* in dll function - string in C# Pin
SasaTod11-Jun-04 5:46
SasaTod11-Jun-04 5:46 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
Heath Stewart11-Jun-04 6:22
protectorHeath Stewart11-Jun-04 6:22 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
SasaTod11-Jun-04 9:29
SasaTod11-Jun-04 9:29 
GeneralRe: C++ pointer char* in dll function - string in C# Pin
Heath Stewart11-Jun-04 10:40
protectorHeath Stewart11-Jun-04 10:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.