July 26, 2005 at 7:36 am
I can get my datagrid into 'edit' mode, enter new data into the textboxes and watch MS SQL Profiler trace the sql syntax showing a definite 'write' procedure, however the data is not in the database. I can 'update' the datagrid successfully and it's trace is identical to my 'Insert' attempt, however no data ever enters the database during 'Insert'.
Q. Why does MS-SQL Profiler show evidence of a 'write' procedure, but no actual data is written to the database.
1. My table has the following layout:
SalesID - int - no null- key - identity
SalesDate - vchar - 50 - nulls
SalesCatagory - vchar - 50 - nulls
2. I have permissions wide-open.
July 26, 2005 at 8:33 am
do you use transactions ?
if yes :
do you commit (data should be there) or rollback (no data will be there) the transaction
Do you handle errors ?
Can you put your insert/update code overhere ?
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 26, 2005 at 12:41 pm
Here's the update procedure from a Microsoft book that I've been using successfully for the 'Update' and seemingly accurate for the 'Insert'. I know it's not an insert syntax, however I'm 'Updating' a blank row in a dataset / datagrid. I figure; What's the difference? I like simple code if It will work properly.......
private
void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{ try { string key = DataGrid1.DataKeys[DataGrid1.EditItemIndex].ToString();
string SQL = @"UPDATE Sales SET SalesDate = @SalesDate, SalesCatagory = @SalesCatagory, "+
WHERE SalesID = @SalesD";
SqlCommand cmd = new SqlCommand(SQL,cn);
cmd.Parameters.Add("@SalesID", key);
cmd.Parameters.Add("@SalesDate", ((TextBox)(e.Item.Cells[2].Controls[0])).Text);
cmd.Parameters.Add("@SalesCatagory", ((TextBox)(e.Item.Cells[3].Controls[0])).Text);
cn.Open(); cmd.ExecuteNonQuery(); cn.Close(); DataGrid1.EditItemIndex = -1; BindGrid();
} catch (Exception exc) { Response.Write(exc.ToString()); } }
July 27, 2005 at 12:30 am
If this is the actual copy, check your applications errorlog (response.write(exc.tostring())) !
You are using "WHERE SalesID = @SalesD"; but the parameter you provide calls it @SalesID
Also check out what sqlserver is receiving for a command and especialy the parameter-order !
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
July 27, 2005 at 7:31 am
That was a typo while posting. It does read "WHERE SalesID = @SalesID";
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply