Update Table gets message "parameter has no default value"
-
Hello all, I am cracking my brains for two weeks now on the following problem: I have to update records on a table but i am now in the stiuation that i get the message "parameter @NummerNaam has no default value" I have posted this question once, thanks for the tips. I also read several documentation but still get stuck. Below my code. Thanks, Bas Dim command As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand("Update Agent" & _ " SET Nummer_Naam = @NummerNaam, Agentnummer = @AgentNummer, Agentnaam = @AgentNaam" & _ " WHERE(Agentnummer = @agentNummerOud)", dcAgent) command.Parameters.Add("@NummerNaam", OleDb.OleDbType.VarChar, 20, "Nummer_Naam") command.Parameters.Add("@AgentNummer", OleDb.OleDbType.Integer, 10, "Agentnummer") command.Parameters.Add("@AgentNaam", OleDb.OleDbType.VarChar, 20, "Agentnaam") Dim parameter As System.Data.OleDb.OleDbParameter = command.Parameters.Add( _ "@agentNummerOud", OleDb.OleDbType.Integer, 10, agentNummerOud) parameter.SourceVersion = DataRowVersion.Original command.Connection.Open() command.ExecuteNonQuery() command.Connection.Close()
-
Hello all, I am cracking my brains for two weeks now on the following problem: I have to update records on a table but i am now in the stiuation that i get the message "parameter @NummerNaam has no default value" I have posted this question once, thanks for the tips. I also read several documentation but still get stuck. Below my code. Thanks, Bas Dim command As System.Data.OleDb.OleDbCommand = New System.Data.OleDb.OleDbCommand("Update Agent" & _ " SET Nummer_Naam = @NummerNaam, Agentnummer = @AgentNummer, Agentnaam = @AgentNaam" & _ " WHERE(Agentnummer = @agentNummerOud)", dcAgent) command.Parameters.Add("@NummerNaam", OleDb.OleDbType.VarChar, 20, "Nummer_Naam") command.Parameters.Add("@AgentNummer", OleDb.OleDbType.Integer, 10, "Agentnummer") command.Parameters.Add("@AgentNaam", OleDb.OleDbType.VarChar, 20, "Agentnaam") Dim parameter As System.Data.OleDb.OleDbParameter = command.Parameters.Add( _ "@agentNummerOud", OleDb.OleDbType.Integer, 10, agentNummerOud) parameter.SourceVersion = DataRowVersion.Original command.Connection.Open() command.ExecuteNonQuery() command.Connection.Close()
You created four parameter objects, but you didn't assign values to any of the parameters. You can change that by doing something like this:
command.Parameters.Add(new OleDbParameter("@NummerNaam", OleDb.OleDbType.VarChar, 20, "Nummer_Naam")).Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNummer", OleDb.OleDbType.Integer, 10, "Agentnummer").Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNaam", OleDb.OleDbType.VarChar, 20, "Agentnaam").Value = somevalueA guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
You created four parameter objects, but you didn't assign values to any of the parameters. You can change that by doing something like this:
command.Parameters.Add(new OleDbParameter("@NummerNaam", OleDb.OleDbType.VarChar, 20, "Nummer_Naam")).Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNummer", OleDb.OleDbType.Integer, 10, "Agentnummer").Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNaam", OleDb.OleDbType.VarChar, 20, "Agentnaam").Value = somevalueA guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
You created four parameter objects, but you didn't assign values to any of the parameters. You can change that by doing something like this:
command.Parameters.Add(new OleDbParameter("@NummerNaam", OleDb.OleDbType.VarChar, 20, "Nummer_Naam")).Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNummer", OleDb.OleDbType.Integer, 10, "Agentnummer").Value = somevalue
command.Parameters.Add(new OleDbParameter("@AgentNaam", OleDb.OleDbType.VarChar, 20, "Agentnaam").Value = somevalueA guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007