T
TJ
Hi All,
I am having some trouble.
I have created a database via the new database option inside VWD2005.
Then and table or two.
I have been able to perform INSERT and SELECT operations on the table, BUT cannot do an UPDATE.
After the update command it says 1 row updated, but the data does not change.
At one point I receieved a message stating something like (heavily paraphrased...):
"Permissions do not allow updating to be performed"
Interestingly enough when I attached to gridview and enable updating it wont allow that to do it either!
I've tried creating clean app, new database, new tables etc and it still happens.
Is this a simple setting, or how I am doing the UPDATE (code below) or the fact that the database is set as a "user" database.
Not a multi-access one. Changin User Instance to False comes up with error anyway. Know how to get around that?
Thanks in advance for your assistance.
Steve
My Update Code:
Dim userDataSource As New SqlDataSource
Dim userResult As New System.Data.DataView
userDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ReportingConnectionString").ToString()
'set the way we will perform select queries
userDataSource.UpdateCommandType = SqlDataSourceCommandType.Text
UserDataSource.UpdateCommand = "UPDATE site_info SET UserName = @UserName, First_Name = @newFirstName, Last_Name = @newSurname, Phone_Number = @newPhoneNumber, Fax_Number = @newFaxNumber WHERE UserName = @UserName"
userDataSource.UpdateParameters.Add("UserName", User.Identity.Name.ToString)
userDataSource.UpdateParameters.Add("newFirstName", firstnameTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newSurname", surnameTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newPhoneNumber", phoneTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newFaxNumber", faxTextBox.Text.ToString)
Try
MsgBox(userDataSource.Update())
Catch ex As Exception
MsgBox(ex.Message)
End Try
userDataSource = Nothing
userResult = Nothing
My Connection String:
<connectionStrings>
<add name="ReportingConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Reporting.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
I am having some trouble.
I have created a database via the new database option inside VWD2005.
Then and table or two.
I have been able to perform INSERT and SELECT operations on the table, BUT cannot do an UPDATE.
After the update command it says 1 row updated, but the data does not change.
At one point I receieved a message stating something like (heavily paraphrased...):
"Permissions do not allow updating to be performed"
Interestingly enough when I attached to gridview and enable updating it wont allow that to do it either!
I've tried creating clean app, new database, new tables etc and it still happens.
Is this a simple setting, or how I am doing the UPDATE (code below) or the fact that the database is set as a "user" database.
Not a multi-access one. Changin User Instance to False comes up with error anyway. Know how to get around that?
Thanks in advance for your assistance.
Steve
My Update Code:
Dim userDataSource As New SqlDataSource
Dim userResult As New System.Data.DataView
userDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ReportingConnectionString").ToString()
'set the way we will perform select queries
userDataSource.UpdateCommandType = SqlDataSourceCommandType.Text
UserDataSource.UpdateCommand = "UPDATE site_info SET UserName = @UserName, First_Name = @newFirstName, Last_Name = @newSurname, Phone_Number = @newPhoneNumber, Fax_Number = @newFaxNumber WHERE UserName = @UserName"
userDataSource.UpdateParameters.Add("UserName", User.Identity.Name.ToString)
userDataSource.UpdateParameters.Add("newFirstName", firstnameTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newSurname", surnameTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newPhoneNumber", phoneTextBox.Text.ToString)
userDataSource.UpdateParameters.Add("newFaxNumber", faxTextBox.Text.ToString)
Try
MsgBox(userDataSource.Update())
Catch ex As Exception
MsgBox(ex.Message)
End Try
userDataSource = Nothing
userResult = Nothing
My Connection String:
<connectionStrings>
<add name="ReportingConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Reporting.mdf;Integrated Security=True;User Instance=True" providerName="System.Data.SqlClient"/>
</connectionStrings>