2014年7月13日 星期日

[RESOLVED] getting problem while updation


hey guys..


i have created a gridview using ms access database


source below.



        DataKeyNames="bill_no" DataSourceID="AccessDataSource1">


SortExpression="bill_no" />
SortExpression="bill_date" />

SortExpression="district" />
SortExpression="branch" />
SortExpression="total_amt" />
SortExpression="comission" />
SortExpression="account_type" />
SortExpression="bill_date_range" />
SortExpression="remarks" />


DataFile="~/App_Data/daksh.mdb"
DeleteCommand="DELETE FROM [bills] WHERE (([bill no] = ?) OR ([bill no] IS NULL AND ? IS NULL))"
InsertCommand="INSERT INTO [bills] ([bill no], [bill date], [bank], [district], [branch], [total amt], [comission], [account type], [bill date range], [remarks]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
SelectCommand="SELECT [bill no] AS bill_no, [bill date] AS bill_date, [bank], [district], [branch], [total amt] AS total_amt, [comission], [account type] AS account_type, [bill date range] AS bill_date_range, [remarks] FROM [bills]"
UpdateCommand="UPDATE [bills] SET [bill date] = ?, [bank] = ?, [district] = ?, [branch] = ?, [total amt] = ?, [comission] = ?, [account type] = ?, [bill date range] = ?, [remarks] = ? WHERE (([bill no] = ?) OR ([bill no] IS NULL AND ? IS NULL))">




























whenever i am using update option its giving me this error.


Exception Details:
System.Data.OleDb.OleDbException: No value given for one or more required parameters.




Remarks: i have the same colums in both database and gridview



Hi,


You may miss some fields in you INSERT Query. Its my guess. Please ensure that.


Hope this helps!


Thanks!



You have 10 update parameters only, so try this : UpdateCommand = "UPDATE [bills] SET [bill date] = ?, [bank] = ?, [district] = ?, [branch] = ?, [total amt] = ?, [comission] = ?, [account type] = ?, [bill date range] = ?, [remarks] = ? WHERE [bill no] = ?"
change delete command also because i think deleting will also not working.

nope. i have 10 columns in the database and here also it have 10 fields to be updated...




You have 11 "?"s in update command and 2 in delete command, you need one more parameter. But you only have bill no

沒有留言:

張貼留言