EDN Admin
Well-known member
Hi
Ive been having a massive problem with this. Have no idea why its happening but Im so sure that its something so little that I cant seem to spot. Heres the code:
//This reads correctly<br/>
public ItemsDTO getItemFromBox(String name) {<br/>
myConn.Open();<br/>
String selectStatement = "SELECT * FROM items WHERE item_name="+name+"";<br/>
OleDbCommand myComm = new OleDbCommand(selectStatement,myConn);<br/>
OleDbDataReader myDR;<br/>
myDR = myComm.ExecuteReader();<br/>
if (!myDR.Read()) return null;<br/>
return makeItemDTO(myDR);<br/>
}<br/>
public ItemsDTO makeItemDTO(OleDbDataReader myDR)<br/>
{<br/>
ItemsDTO myItem = new ItemsDTO();<br/>
myItem.itemId = myDR.GetInt32(0);<br/>
myItem.serialNum = myDR.GetString(1);<br/>
myItem.itemName = myDR.GetString(2);<br/>
myItem.companyName = myDR.GetString(3);<br/>
myItem.descr = myDR.GetString(4);<br/>
myItem.category = myDR.GetString(5);<br/>
myItem.availablity = myDR.GetString(6);<br/>
//myItem.fkCheckoutListId = myDR.GetInt32(7);<br/>
myConn.Close();<br/>
return myItem;<br/>
}<br/>
//myDR = myComm.ExecuteReader() seems to hit an error here<br/>
public StaffDTO getStaffFromBox(String name)<br/>
{<br/>
//myConn = new OleDbConnection(MyConnString);<br/>
myConn.Open();<br/>
String selectStatement = "SELECT * FROM staff WHERE staff_name=" + name + "";<br/>
OleDbCommand myComm = new OleDbCommand(selectStatement, myConn);<br/>
OleDbDataReader myDR;<br/>
myDR = myComm.ExecuteReader();<br/>
if (!myDR.Read()) return null;<br/>
return makeStaffDTO(myDR);<br/>
}<br/>
public StaffDTO makeStaffDTO(OleDbDataReader myDR)<br/>
{<br/>
StaffDTO staff = new StaffDTO();<br/>
staff.staffId = myDR.GetInt32(0);<br/>
staff.firstname = myDR.GetString(1);<br/>
staff.lastname = myDR.GetString(2);<br/>
staff.address = myDR.GetString(3);<br/>
staff.fkDeptId = myDR.GetInt32(4);<br/>
return staff;<br/>
}
Heres the error it displays:
<pre style="font-family:Lucida Console; font-size:0.9em; line-height:normal; background-color:#ffffcc Line 50: OleDbCommand myComm = new OleDbCommand(selectStatement, myConn);
Line 51: OleDbDataReader myDR;
<span style="color:red Line 52: myDR = myComm.ExecuteReader();
Line 53: if (!myDR.Read()) return null;
Line 54: return makeStaffDTO(myDR);[/code]
<pre style="font-family:Lucida Console; font-size:0.9em; line-height:normal; background-color:#ffffcc [OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1081420
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +116
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
ACSWebAppDAO.getStaffFromBox(String name) in c:WebSitesACSWeb2_SQLApp_CodeACSWebAppDAO.cs:52
ACS_App.btnCheckOut_Click(Object sender, EventArgs e) in c:WebSitesACSWeb2_SQLACS_viewData.aspx.cs:91
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563[/code]
I see that it says "no value given", but it just doesnt make sense to me because the ItemsDTO works.
Please guys. I really hope you can help me
View the full article
Ive been having a massive problem with this. Have no idea why its happening but Im so sure that its something so little that I cant seem to spot. Heres the code:
//This reads correctly<br/>
public ItemsDTO getItemFromBox(String name) {<br/>
myConn.Open();<br/>
String selectStatement = "SELECT * FROM items WHERE item_name="+name+"";<br/>
OleDbCommand myComm = new OleDbCommand(selectStatement,myConn);<br/>
OleDbDataReader myDR;<br/>
myDR = myComm.ExecuteReader();<br/>
if (!myDR.Read()) return null;<br/>
return makeItemDTO(myDR);<br/>
}<br/>
public ItemsDTO makeItemDTO(OleDbDataReader myDR)<br/>
{<br/>
ItemsDTO myItem = new ItemsDTO();<br/>
myItem.itemId = myDR.GetInt32(0);<br/>
myItem.serialNum = myDR.GetString(1);<br/>
myItem.itemName = myDR.GetString(2);<br/>
myItem.companyName = myDR.GetString(3);<br/>
myItem.descr = myDR.GetString(4);<br/>
myItem.category = myDR.GetString(5);<br/>
myItem.availablity = myDR.GetString(6);<br/>
//myItem.fkCheckoutListId = myDR.GetInt32(7);<br/>
myConn.Close();<br/>
return myItem;<br/>
}<br/>
//myDR = myComm.ExecuteReader() seems to hit an error here<br/>
public StaffDTO getStaffFromBox(String name)<br/>
{<br/>
//myConn = new OleDbConnection(MyConnString);<br/>
myConn.Open();<br/>
String selectStatement = "SELECT * FROM staff WHERE staff_name=" + name + "";<br/>
OleDbCommand myComm = new OleDbCommand(selectStatement, myConn);<br/>
OleDbDataReader myDR;<br/>
myDR = myComm.ExecuteReader();<br/>
if (!myDR.Read()) return null;<br/>
return makeStaffDTO(myDR);<br/>
}<br/>
public StaffDTO makeStaffDTO(OleDbDataReader myDR)<br/>
{<br/>
StaffDTO staff = new StaffDTO();<br/>
staff.staffId = myDR.GetInt32(0);<br/>
staff.firstname = myDR.GetString(1);<br/>
staff.lastname = myDR.GetString(2);<br/>
staff.address = myDR.GetString(3);<br/>
staff.fkDeptId = myDR.GetInt32(4);<br/>
return staff;<br/>
}
Heres the error it displays:
<pre style="font-family:Lucida Console; font-size:0.9em; line-height:normal; background-color:#ffffcc Line 50: OleDbCommand myComm = new OleDbCommand(selectStatement, myConn);
Line 51: OleDbDataReader myDR;
<span style="color:red Line 52: myDR = myComm.ExecuteReader();
Line 53: if (!myDR.Read()) return null;
Line 54: return makeStaffDTO(myDR);[/code]
<pre style="font-family:Lucida Console; font-size:0.9em; line-height:normal; background-color:#ffffcc [OleDbException (0x80040e10): No value given for one or more required parameters.]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr) +1081420
System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult) +247
System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult) +194
System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult) +58
System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +167
System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior) +116
System.Data.OleDb.OleDbCommand.ExecuteReader() +6
ACSWebAppDAO.getStaffFromBox(String name) in c:WebSitesACSWeb2_SQLApp_CodeACSWebAppDAO.cs:52
ACS_App.btnCheckOut_Click(Object sender, EventArgs e) in c:WebSitesACSWeb2_SQLACS_viewData.aspx.cs:91
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563[/code]
I see that it says "no value given", but it just doesnt make sense to me because the ItemsDTO works.
Please guys. I really hope you can help me
View the full article