DataGridView/SQL Express - Updating Record Using Seperate Form

Dec 7, 2006

Hi,

I am currently using VC++/Cli 2005. In a project, I'm using a DataGridView control to show records from a SQL Express 2005 table. Instead of updating a specific item directly within DataGridView control, I would like to open a new form and allow user to update selected record/item within that form. The reason to update this way is conditionned by the fact that I have 3 levels of detail as following:

Level 0 Level 1 Level 2

1:N 1:N
Furniture --> Component --> Component


You all understand that update form of Level1 will/must include, as Level0 do, another DataGridView control to display/detail all related items issued from next level. This explains why I can't allow user to update Level 1 directly from DataGridView control.

I've searched in MSDN and even bought a few books on subject but unfortunately I found nothing on how to do it this way. All articles on DataGridView control were only showing how to update record directly from control.

My approach, I think, would be to transmit to my level1 updating form, as a single parameter, the selected DataRow object (or a brand new one if currently adding) issued from DataGridView and let user update it's content. When User finally leaves level0 update form, then I presume that DataGridView corresponding table would be automatically updated according to DataGridView's content.

What would be the proper way to do it? I would certainly appreciate to hear you view on this.

Also, what can I do if I want to refresh DataGridView's content when coming back from update form. Is it done automatically? I would certainly be sure that it reflects the reality, not only when I update it myself but also especially when other users could concurrently update same records?

Thanks in advance,

Stéphane

View 7 Replies


ADVERTISEMENT

Updating Master DB With Seperate Data

Nov 15, 2004

Hey all, Here is what I would like to do.. if any can give some advice or direction with this i would appreciate it.

We have a "master database" (MS SQL) at our main office. Then a smaller office with only a dial-up connection. Can I have my db application write all the data input to a local DB. Then write something to connect with the master DB, through a Terminal server, etc., and update it with the data from the other smaller db?

View 1 Replies View Related

DataGridView: How Can I Update Data In A DataGridView?

Jan 11, 2007

Hi guys,



Im having some issues understanding how to manipulate the data that is in my DataGridView

The View is created by calling a stored procedure from VB code and works on two tables:

people
pswds

The columns required from Table people are (personid, userid and sort).

The columns required from Table pswds are (comment and activeuser).

Table people is parent table while pswds is the child table.

The Relationship works between both tables using primary keys from both tables: which is called personid in both.

The link below shows the Relationship Diagram for the Two tables:


http://cale.csd.anglia.ac.uk/~csd03ib/images/RelationTables.bmp
The code for the Stored procedure can be found at the following Link:

http://cale.csd.anglia.ac.uk/~csd03ib/images/StoredProcedure.bmp
Now the DataGridView returned by the Stored procedure produces the following output found at this link:

http://cale.csd.anglia.ac.uk/~csd03ib/images/DataGridView.bmp
Of course there are many more results returned for this DataGridView but i have only shown a few of them. What i really need to know is:
Can this view be made to be editable?
I need to be able to update the both the Active user Check box and the Comment Columns from this view
I hope someone can help
Thx Flakky

View 8 Replies View Related

Query Timeouts When Updating A Record Retrieved Through A Websphere JDBC Datasource - Possible Record Locking Problem

Apr 7, 2008

Hi,

We're running a Sage CRM install with a SQL Server 2000 database at the back end. We're using the Sage web services API for updating data and a JDBC connection to retrieve data as it's so much quicker.

If I retrieve a record using the JDBC connection and then try and update the same record through the web services, the query times out as if the record is locked for updates. Has anyone experienced anything similar or know what I'm doing wrong? If I just use DriverManager.getConnection() to establish the connection instead of the datasource, and then continue with the same code I don't get these record locking problems. Please find more details below.

Thanks,
Sarah

The JDBC provider for the datasource is a WebSphere embedded ConnectJDBC for SQL Server DataSource, using an implementation type of 'connection pool datasource'. We are using a container managed J2C authentication alias for logging on.

This is running on a Websphere Application Server v6.1.

Code snippet - getting the record thru JDBC:


DataSource wsDataSource = serviceLocator.getDataSource("jdbc/dsSQLServer");
Connection wsCon = wsDataSource.getConnection();


// wsCon.setAutoCommit(false); //have tried with and without this flag - same results

Statements stmt = wsCon.createStatement();


String sql = "SELECT * FROM Person where personID = 12345";
ResultSet rs = stmt.executeQuery(sql);


if(rs.next()){
System.out.println(rs.getString("lastName"));
}

if (rs != null){
rs.close();
}
if (stmt != null) {

stmt.close();
}
if (wsCon != null) {

wsCon.close();
}

View 1 Replies View Related

Inserting/ Updating More Than One Table From A Single Web Form

Apr 22, 2008

 i wanted to ask how to insert values from a single web form into two sql tables, i have been looking and the visual web developer i use doesnt seam to allow me to even atempt it i've tried selecting all the values from two different tables and then adding those two tables to an insert function but it doesnt work likewise the update functioni have values in a table currently a reference number and i want to use this reference number to update the address values in this table so update this field.table1 and thisfield.table2 when ref number = @ refnumber the reference number is present in both tables and is linked PK to FK  <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:Back End DataConnectionString %>"
SelectCommand="SELECT StartDetails.StartDetailsID, StartDetails.ContractIDNo, StartDetails.ContractName, StartDetails.NINO, StartDetails.AnticipatedStartDate, StartDetails.StartDateTime, StartDetails.StartDateLetterSent, StartDetails.StartDate, StartDetails.AnticipatedEndDate, StartDetails.ActualEndDate, StartDetails.ReasonForLeaving, StartDetails.Provider, StartDetails.AdviserReferrer, StartDetails.ProvisionCat, StartDetails.Provision, ClientDetails.NINO AS Expr1, ClientDetails.CentreNo, ClientDetails.FirstName, ClientDetails.SecondName, ClientDetails.AddressLine1, ClientDetails.AddressLine2, ClientDetails.PostCode, ClientDetails.ContactTelephoneNumber, ClientDetails.MobileNo, ClientDetails.Email, ClientDetails.DateOfBirth, ClientDetails.Gender, ClientDetails.PWD, ClientDetails.Ethnicity, ClientDetails.ClientGroup, ClientDetails.RepeatStartDate, ClientDetails.CaseworkerName, ClientDetails.ClientStatus, ClientDetails.PlacementDates, ClientDetails.JobsearchDay, ClientDetails.AchievedILP, ClientDetails.JobDate, ClientDetails.JobDate2, ClientDetails.JobDate3, ClientDetails.EligibleForRolledUpWeeks, ClientDetails.NoOfWeeksClaimed, ClientDetails.MarketingWhere, ClientDetails.Notes, ClientDetails.JobCentre, ClientDetails.JobCentreRep FROM StartDetails INNER JOIN ClientDetails ON StartDetails.NINO = ClientDetails.NINO WHERE (StartDetails.StartDetailsID = @StartDetailsID) AND (StartDetails.NINO = @NINO)"
InsertCommand="INSERT INTO [StartDetails] ([NINO], [StartDate], [AnticipatedEndDate]) VALUES (@NINO, @StartDate, @AnticipatedEndDate)"

UpdateCommand="UPDATE [StartDetails] SET [StartDate] = @StartDate, [AnticipatedEndDate] = @AnticipatedEndDate WHERE [StartDetailsID] = @StartDetailsID,[NINO] = @NINO">
<SelectParameters>
<asp:QueryStringParameter Direction="InputOutput" Name="StartDetailsID"
QueryStringField="StartDetailsID" />
<asp:QueryStringParameter Direction="InputOutput" Name="NINO"
QueryStringField="NINO" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="AnticipatedEndDate" Type="DateTime" />
<asp:Parameter Name="StartDetailsID" Type="Int32" />
<asp:Parameter Name="NINO" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="NINO" />
<asp:Parameter Name="StartDate" Type="DateTime" />
<asp:Parameter Name="AnticipatedEndDate" Type="DateTime" />
</InsertParameters>
</asp:SqlDataSource>   your coinsideration is appreciatedChris  

View 4 Replies View Related

Updating Database From Form Error Message

Jan 19, 2005

I am getting an error message when trying to up to update a database from a form. It appears a simple looking error but I can't seem to see what the problem is
Any ideas would be appreciated

This is the error message
Line 1: Incorrect syntax near '('.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect syntax near '('.

Source Error:


Line 95: sqlConnection.Open
Line 96: Try
Line 97: rowsAffected = sqlCommand.ExecuteNonQuery
Line 98: Finally
Line 99: sqlConnection.Close


Source File: D:Webspacewebs4cInetpubwwwrootkerslakeAdminUpdate.aspx Line: 97

Stack Trace:


[SqlException: Line 1: Incorrect syntax near '('.]
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) +742
System.Data.SqlClient.SqlCommand.ExecuteNonQuery() +194
ASP.Update_aspx.Update(Int32 lifestyleID, String clientFirstName, String clientSurname, String clientStreet, String clientTown, String clientState, String clientPhone, String clientMOB, String clientEmail, Int32 methodContact, String occupation, String selfEmployed, String company, String address, String other, String progress, DateTime lastUpdate, String dOB, String prefferedTime) in D:Webspacewebs4cInetpubwwwrootkerslakeAdminUpdate.aspx:97
ASP.Update_aspx.Update(Object Source, EventArgs E) in D:Webspacewebs4cInetpubwwwrootkerslakeAdminUpdate.aspx:321
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1292

THIS IS THE CODE>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Function Update( _
ByVal lifestyleID As Integer, _
ByVal clientFirstName As String, _
ByVal clientSurname As String, _
ByVal clientStreet As String, _
ByVal clientTown As String, _
ByVal clientState As String, _
ByVal clientPhone As String, _
ByVal clientMOB As String, _
ByVal clientEmail As String, _
ByVal methodContact As Integer, _
ByVal occupation As String, _
ByVal selfEmployed As String, _
ByVal company As String, _
ByVal address As String, _
ByVal other As String, _
ByVal progress As String, _
ByVal lastUpdate As Date, _
ByVal dOB As String, _
ByVal prefferedTime As String) As Integer
Dim connectionString As String = "server='202.xxxxxxx; user id='webs4c'; password='xxxxxxx'; database='xxxx'"
Dim sqlConnection As System.Data.SqlClient.SqlConnection = New System.Data.SqlClient.SqlConnection(connectionString)
Dim queryString As String = "UPDATE [Lifestyle] ([LifestyleID], [ClientFirstName], [ClientSurname], [ClientStr"& _
"eet], [ClientTown], [ClientState], [ClientPhone], [ClientMOB], [ClientEmail], [M"& _
"ethodContact], [Occupation], [SelfEmployed], [Company], [Address], ["& _
"Other], [Progress], [LastUpdate], [DOB], [PrefferedTime]) VALUES "& _
"(@UserID, @ClientFirstName, @ClientSurname, @ClientStreet, @ClientTown, @ClientS"& _
"tate, @ClientPhone, @ClientMOB, @ClientEmail, @MethodContact, @Occupation, @Self"& _
"Employed, @Company, @Address, @Other,@Progress, @LastU"& _
"pdate, @DOB, @PrefferedTime WHERE ([Lifestyle].[L"& _
"ifestyleID] = @LifestyleID)"

Dim sqlCommand As System.Data.SqlClient.SqlCommand = New System.Data.SqlClient.SqlCommand(queryString, sqlConnection)

sqlCommand.Parameters.Add("@LifestyleID", System.Data.SqlDbType.Int).Value = lifestyleID
sqlCommand.Parameters.Add("@ClientFirstName", System.Data.SqlDbType.NVarChar).Value = clientFirstName
sqlCommand.Parameters.Add("@ClientSurname", System.Data.SqlDbType.NVarChar).Value = clientSurname
sqlCommand.Parameters.Add("@ClientStreet", System.Data.SqlDbType.NVarChar).Value = clientStreet
sqlCommand.Parameters.Add("@ClientTown", System.Data.SqlDbType.NVarChar).Value = clientTown
sqlCommand.Parameters.Add("@ClientState", System.Data.SqlDbType.NVarChar).Value = clientStreet
sqlCommand.Parameters.Add("@ClientPhone", System.Data.SqlDbType.NVarChar).Value = clientPhone
sqlCommand.Parameters.Add("@ClientMOB", System.Data.SqlDbType.NVarChar).Value = clientMOB
sqlCommand.Parameters.Add("@ClientEmail", System.Data.SqlDbType.NVarChar).Value = clientEmail
sqlCommand.Parameters.Add("@MethodContact", System.Data.SqlDbType.Int).Value = methodContact
sqlCommand.Parameters.Add("@Occupation", System.Data.SqlDbType.NVarChar).Value = occupation
sqlCommand.Parameters.Add("@SelfEmployed", System.Data.SqlDbType.NVarChar).Value = selfEmployed
sqlCommand.Parameters.Add("@Company", System.Data.SqlDbType.NVarChar).Value = company
sqlCommand.Parameters.Add("@Address", System.Data.SqlDbType.NVarChar).Value = address
sqlCommand.Parameters.Add("@Other", System.Data.SqlDbType.NVarChar).Value = other
'sqlCommand.Parameters.Add("@DateEnquiry", System.Data.SqlDbType.DateTime).Value = dateEnquiry
sqlCommand.Parameters.Add("@Progress", System.Data.SqlDbType.NVarChar).Value = progress
sqlCommand.Parameters.Add("@LastUpdate", System.Data.SqlDbType.DateTime).Value = lastUpdate
sqlCommand.Parameters.Add("@DOB", System.Data.SqlDbType.NVarChar).Value = dOB
sqlCommand.Parameters.Add("@PrefferedTime", System.Data.SqlDbType.NVarChar).Value = prefferedTime

Dim rowsAffected As Integer = 0
sqlConnection.Open
Try
rowsAffected = sqlCommand.ExecuteNonQuery
Finally
sqlConnection.Close
End Try

Return rowsAffected
End Function

END CODE

View 2 Replies View Related

Using A Web Form To Append A Record To A SQL Table

Dec 30, 2006

How to I make it so that a Authenticated User to a website can append a record to a SQL table.  I have watched the video on the asp.net website about using database on a web, it shows how to allow a user to change a record in a database, but nothing I have seen so far shows how they can append a record.
 
What I am trying to do:  I am building a website for a ATV club using Visual Studio 2005 and c#.  I am setting up users or members on the site (club members will have a user account, while all others will be un-authenticated users.  I am setting up a classifieds area where members can post items for sale, items they are looking for, etc. 
 
I am planning to use roles to allow authenticated users access to a webpage located in a restricted directory.  There I want to place a XHTML page which would allow the users to post their classified ads for free.  I will have another page that will allow everyone to view the ads not just club members.  I want to make this as easy to maintain as possible.   I don’t plan on having all the postings come through me to be placed on the web, I want it all automated. 

View 2 Replies View Related

If All What I Used Is The Express Version - Is It Possible To Connect And Use The Sql.s Express Form The Vs. Express

Apr 14, 2008


Hello
I got a sql server express that i am trying to connect form win or web forms(2.0) €“ express as well.

My problem:
Can not connect to the server in any way!
Even the designer cont find any sql server on my machine; for example "the data source configuration manager" (gui) in enyn way its can not find the sql server express (2005)

So my question is:
if all what i used is the express version - is it possible to connect and use the sql.s express form the vs. express

View 10 Replies View Related

Connection Issue To SQL Express Form VB Express

Feb 1, 2007

Anyone know how to fix this error:

System.Data.SqlClient.SqlException was unhandled
Class=16
ErrorCode=-2146232060
LineNumber=65536
Message="Directory lookup for the file "C:Documents and Settingszimmerman_eMy DocumentsVisual Studio 2005ProjectsMGM_REPORTSMGM_REPORTSImportFile.mdf" failed with the operating system error 5(Access is denied.).
Could not attach file 'C:Documents and Settingszimmerman_eMy DocumentsVisual Studio 2005ProjectsMGM_REPORTSMGM_REPORTSImportFile.mdf' as database 'dbname'."
Number=5133
Procedure=""
Server=".SQLExpress"
Source=".Net SqlClient Data Provider"
State=1
StackTrace:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at MGM_REPORTS.DbConnect.InsertSQL(String[] Values) in C:Documents and Settingszimmerman_eMy DocumentsVisual Studio 2005ProjectsMGM_REPORTSMGM_REPORTSDbConnect.vb:line 149
at MGM_REPORTS.DbConnect.btnConnectDB_Click(Object sender, EventArgs e) in C:Documents and Settingszimmerman_eMy DocumentsVisual Studio 2005ProjectsMGM_REPORTSMGM_REPORTSDbConnect.vb:line 21
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at MGM_REPORTS.DbConnect.Main() in C:Documents and Settingszimmerman_eMy DocumentsVisual Studio 2005ProjectsMGM_REPORTSMGM_REPORTSDbConnect.vb:line 158
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

View 4 Replies View Related

How To Make Form To Delete Record From Table In Access 2002

Jun 29, 2004

I like to give First Name and Last Name in two different text box and then hit the delete button (command button). Then it will do a query to find the person and delete the corresponding record from the table. Any kind of help will be appreciated. Thank you.

View 1 Replies View Related

Updating A Record

Nov 17, 2004

Hello, I'm new to SQL, I need to HtmlEncode a column in all my records in a table, how can i construct my sql string? I have the following...

Cmd = "UPDATE articulos SET DescripcionCorta = HtmlEncode(DescripcionCorta) WHERE codigo='x'"

All I need is to Encode my "DescripcionCorta" Field.

Regards.

Roberto.

View 6 Replies View Related

Updating Record In Table

Jun 9, 2008

Hi all, I'm new to SQL and have been trying to update a record in a table, something I imagine would be quite simple. The record holds a INT value and I wish to test the value to see if it is greater than 70, if it is....reset the value to 1

I have tried various methods, aiming at using a stored procedure that will run once a day at midnight.

Any help would be great.

Abbo

View 4 Replies View Related

How To Find Updating A Record In .net

Sep 23, 2007

Hello
I need an alarm or raise an event from SQL Server after updating to get it in .net.
I use SQL Server 2005 Express Edition and vb.net2 for my programming language.
Suppose that in a windows form I have a grid and I'm working with this page
another client is working with this same page .He is editing the information of
a record of a grid and save it in database so I want to give an alarm or an event
that raise from SQL Server (for example in a trigger) , what can I do?
Thanks.

View 3 Replies View Related

Has Anyone Had Trouble Updating A Record Before?

Mar 23, 2008

Hi, I have a problem, it is that when I try to update a record in my SQL server database, it is not updated and I recieve no error messages. This is the code behind the update button. The stored procedure is "sqlupdate".











Code Snippet

Dim ListingID As String = Request.QueryString("id").ToString
Dim con As New SqlConnection(ListingConnection)
Dim cmd As New SqlCommand("sqlupdate", con)
cmd.CommandType = CommandType.StoredProcedure
Dim id As SqlParameter = cmd.Parameters.Add("@id", SqlDbType.UniqueIdentifier)
id.Direction = ParameterDirection.Input
id.Value = ListingID

Dim PlaceName As SqlParameter = cmd.Parameters.Add("@PlaceName", SqlDbType.VarChar)
PlaceName.Direction = ParameterDirection.Input
PlaceName.Value = PlaceNameTB.Text

Dim Location As SqlParameter = cmd.Parameters.Add("@Location", SqlDbType.VarChar)
Location.Direction = ParameterDirection.Input
Location.Value = LocationTB.Text

Dim PropertyType As SqlParameter = cmd.Parameters.Add("@PropertyType", SqlDbType.VarChar)
PropertyType.Direction = ParameterDirection.Input
PropertyType.Value = PropertyTypeTB.Text

Dim Description As SqlParameter = cmd.Parameters.Add("@Description", SqlDbType.VarChar)
Description.Direction = ParameterDirection.Input
Description.Value = DescriptionTB.Text

Try
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As Exception

End Try

View 3 Replies View Related

Updating A Record: ExecuteNonQuery

Apr 10, 2008

I'm using VB.Net 2008 with SQL Compact 3.5. After trying forever, I finally got my app to open a retrieve a record from a table. Now, when I try to update the record, I get an error on the ExecuteNonQuery statement. The error says I am "attempting to read or write protected memory". The code works perfectly with an Access database.

Here is the code I am using:

Dim objConnection As Data.OleDb.OleDbConnection

Dim objCommand As Data.OleDb.OleDbCommand

Dim sConnection As String

Dim sTableName As String

Try

'Set Table Name

sTableName = "Settings"

'Build SQL and Connection strings

'sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & mstrDataPath

sConnection = "Provider=Microsoft.SQLSERVER.CE.OLEDB.3.5;Data Source=" & mstrDataPath

objConnection = New Data.OleDb.OleDbConnection(sConnection)

'Create the UpdateCommand

objCommand = New Data.OleDb.OleDbCommand("UPDATE " & sTableName & " SET " & _

"OwnerName = ?, " & _

"Address1 = ?, " & _

"Address2 = ?, " & _

"City = ?, " & _

"State = ?, " & _

"ZipCode = ?, " & _

"Phone = ?, " & _

"EmailAddress = ? ", objConnection)

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(0).Value = mstrOwnerName

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(1).Value = mstrAddress1

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(2).Value = mstrAddress2

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(3).Value = mstrCity

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(4).Value = mstrState

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(5).Value = mstrZipCode

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(6).Value = mstrPhone

objCommand.Parameters.Add(New Data.OleDb.OleDbParameter)

objCommand.Parameters(7).Value = mstrEmailAddress


objConnection.Open()

objCommand.ExecuteNonQuery()

objConnection.Close()

objCommand.Dispose()

UpdateRecord = True

Catch objException As Exception

UpdateRecord = False

MessageBox.Show(objException.ToString, "Error")

End Try

View 21 Replies View Related

Updating A Database Record Without Using An ASP Component.

Jan 27, 2008

Hello, i currently have a gridview component displaying data from a SQLSERVER2005 database. I have created an 'edit' hyperlink on each record so that when pressed, the primary key of a record is sent in the querystring to another page when pressed. example http://localhost/Prog/EditAppointment.aspx?AppointmentId=1
In the edit page, i have dragged and dropped a sqldatasource that contains the select and update statements. i would now like to use textboxes and dropdowns to display the data for the particular record selected (in this case appointmentid=1). however i dont want to use a formview or automated component, just to drag and drop the textboxes myself. how do i bind the textboxes in the HTML code to the data from the select statement? My current select parameters look as follows.
<SelectParameters>
<asp:QueryStringParameter Name="AppointmentId" QueryStringField="AppointmentId" Type="Int32" />
<asp:ControlParameter ControlID="Textbox1" Name="PatientNo" PropertyName="Text" Type="String" />
</SelectParameters>
Perhaps there is an error in my select parameters or does the problem lay elsewhere? Any help would be appreicated.
Thanks,
James.

View 1 Replies View Related

Updating A Table By Looping Through All The Record

Oct 1, 2004

The process of adding a column with DEFAULT (0) to a table that has 15million records takes a despicable amount of time (too much time) and the transaction log of the database grew to an unacceptable size. I would like to accomplish the same task using this procedure:

·Add the column to the table with null value.
·Loop through the table (500000 records at a time) and SET the value in the newly added column to 0.
·Issue a commit statement after each batch
·Issue a checkpoint statement after each batch.
·Alter the table and SET the column to NOT Null DEFAULT (0)


Here is my Sample script


ALTER TABLE EMPLOYEE ADD EZEVALUE NUMERIC (9,6) NULL
Go

Loop
UPDATE EMPLOYEE SET EZEVALUE = 0
Commit Tan
CHECKPOINT
END (Repeat the loop until the rows in EMPLOYEE have the value 0)

Go

ALTER TABLE EMPLOYEE ALTER COLUMN EZEVALUE NUMERIC (9,6) NOT NULL DEFAULT (0)


My problem is with the loop section of this script. How do I structure the loop section of this script to loop through the employee table and update the EZEVALUE column 500000 rows at a time, issue a Commit Tran and a CHECKPOINT statement until the whole table has been updated. Does anyone out there know how to accomplish this task? Any information would be greatly appreciated.


Thanks in advance

View 5 Replies View Related

Asp.net Form Submit To Sql Server Express

Sep 30, 2007

pls i have asp.net page that i want to connect to sql server express edition database and i want data to be submited from the page into sql server express edition database that i have in my project folder when i click on submit button pls help me with the code to do this

View 1 Replies View Related

Problem Updating A Record Based On A Datetime.

Sep 24, 2007

Hi People,
hope someone can help me out here with a little problem.
 Basically i've go a asp.net page which has a listbox on. This list box is populated from a SQL database table with the datetime of the a selected field. Thus in the list box you get a list of strings looking like this "24/09/07 12:58"
Also on the page is a submit button, and some other editing textboxes. The main issue here is the when the submit button is used i get the currently selected listbox timedate string and then pass this along with other items to update a record in the database based on the datetime in the listbox control.
 
Below is how i get the string from the listbox control
Dim except_time As DateTime
except_time = DropDownList1.SelectedValue
The expect_time is then passed to store procedure along with some other vars, which looks like this 
-- =============================================-- Author: Lee Trueman-- Create date: 1st Sept 2007-- =============================================CREATE PROCEDURE [dbo].[spExcept_UpdateData]  -- Add the parameters for the stored procedure here @validated bit, @update_time datetime, @except_time datetimeASBEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON
     -- Insert statements for procedure here UPDATE exceptions SET    validated = @validated,    update_time = @update_time WHERE  (except_time = @except_time)END
So validated and update_time should be updated when except_time is equal to @except_time
 
My problem is that the database never updates. If i debug the asp.net page the watch var shows the datetime in US format (I.e "09/24/07 12:58"), if this is true then this would explain why when it is passed to the stored proc nothing gets updated, as there would not be a date match.
can anyone see any silly mistakes i'm doing here ???? 

View 2 Replies View Related

Updating Field Based On Record Count

Oct 18, 2004

I am trying to write a stored procedure that updates a value in a table based on the sort order. For example, my table has a field "OfferAmount". When this field is updated, I need to resort the records and update the "CurrRank" field with values 1 through whatever. As per my question marks below, I am not sure how to do this.


Update CurrRank = ??? from tblAppKitOffers
where appkitid = 3 AND (OfferStatusCode = 'O' OR OfferStatusCODE = 'D')
ORDER BY tblAppKitOffers.OfferAmount Desc


All help is greatly appreciated.

View 2 Replies View Related

Updating A Record On A SQL 6.5 From Data In SQL 2000 Server

Sep 30, 2004

I need to update one row in a SQL Server 6.5 DB from a row in SQL 2000 server DB. What would be the best way to do this?


I have my 2000 server defined as a Remote Server in 6.5, however I get the error message:

contains more than the maximum number of prefixes. The maximum is 2.

View 9 Replies View Related

Expert On SQL Queries Needed For Help Updating Record.

Mar 23, 2008

Hi, I need help with updating a record. When I run the following code underneath the update button, the record does not update and I get no error message. Anyone have any ideas?





Code Snippet

Dim ListingID As String = Request.QueryString("id").ToString
Dim Description As String = DescriptionTB.Text
Dim PlaceName As String = PlaceNameTB.Text
Dim Location As String = LocationTB.SelectedValue
Dim PropertyType As String = LocationTB.SelectedValue
Dim Price As Integer = PriceTB.Text
Dim con As New SqlConnection(ListingConnection)

Dim sql As String = "Update Listings SET Description = ?, PlaceName = ?, Location = ?, PropertyType = ?, Price = ? WHERE ListingID = ?"
Dim cmd As New SqlCommand(Sql, con)

cmd.Parameters.AddWithValue("Description", Description)
cmd.Parameters.AddWithValue("PlaceName", PlaceName)
cmd.Parameters.AddWithValue("Location", Location)
cmd.Parameters.AddWithValue("PropertyType", PropertyType)
cmd.Parameters.AddWithValue("Price", Price)

Try
con.Open()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As Exception

View 4 Replies View Related

Updating Batch Record After Exporting Data

Aug 19, 2006

I created a package in SSIS to export data from mutiple SQL server tables to a single flat file. Once the export is completed i need to update 2 tables ( a batch table and a history table) In the batch table I need to insert a record with batch # (system generated),batch date, status( success/failed), record count( no of records in the flat file), batch filename). In the history table, i need to insert a record for each of the rows in the flat file with the foll info. batch number,datetime,status(success/failed)

My question is how do I get the batch status,record count, batchfilename for batch table update and how do i get to update the history table.

BTW, i am executing this package as a SQL Server Agent job.
I am new to Integration Services and feel lost.
Any help ?

View 8 Replies View Related

Can Not Connect Form Management Stuido To Express

Feb 25, 2008

I just got a dedicated server to run my websites and SQL Server and MS SQL 2005 Express was installed as it will be more then enough to handle the needs of my DBs right now. The problem I am getting is that when I try to connect to the server from Management Stuido Exrpess (from the server it's self) I recive this error:

quote:provider: Named Pipes Provider, error:40 - Could not open a connection to SQL Server Microsoft SQL Server, Error: 2

And when from a remote computer I get:
quote:provider: Named Pipes Provider, error:40 - Could not open a connection to SQL Server Microsoft SQL Server, Error: 53

I have gone into the Service Area Configuration and made sure that it is set to accept TCP/IP and Named Pipes connection from remote computers and then restarted the dataebase engine.

Can anyone help me? Since this is a dedicated server I have to pay for there support and want to see if I can avoide that

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

View 3 Replies View Related

Updating Database Record Explicitly On Power Turn Off

Dec 18, 2007

HI all,
I have a windows application which runs a process,

I am updating database column "Status" with Processing when the application is running, and on completion I update it with Staus="Completed" or in case I close the application
I update db with Status="Interupted" .

I have problem that in case while proces is running, power supply or system turns off, the db Status="Processing", but in actual it is interupted.
How will i update?

Please help.

View 1 Replies View Related

Unspecified Error When Inserting/updating Record Using SqlCeResultSet On Sql Compact

Nov 14, 2007

Hi,

Inside a single transaction I'm inserting/updating multiple records into multiple tables, in this order:
table 1 record 1
table 2 record 1
table 3 record 1
table 1 record 2
table 2 record 1
table 1 record 3
table 2 record 3
table 3 record 3


Now I'm getting an unspecified error on a certain table:

Unspecified error [ 3,-1300704038,-1834095882,activitypointerBase,x lock (x blocks),PAG (idx): 1078 ]


From msdn I see that:


PAG (idx) means a lock on an index page.

x lock means an exclusive lock:

Indicates a data modification, such as an insert, an update, or a deletion. Ensures that multiple updates cannot be made to the same resource at the same time. (I assume that multiple updates within the SAME transaction can be made, only multiple updates from different transaction cannot be made, right?)
I cannot find any reference to this error message and don't know what the numbers mean. Maybe it relates to data that can be found in the sys.lock_information table like explained here, http://technet.microsoft.com/en-us/library/ms172932.aspx, but I'm not sure.

Furthermore, the sys.lock_information table is empty. I haven't been able to reproduce the problem myself. I only received an error log and the database to investigate it.

So, does anybody have an idea what this error message means and what I can do to troubleshoot this?

Thanks,
Jeffry

View 3 Replies View Related

Datagridview Problem

Feb 18, 2008

Hi.
i created a small database with a table to store two numbers and the sum. num1,num2 and sum column. In sql i used the computed columns specification to assign sum as num1+num2.

running the database, everything works fine. i input the numbers and the sum is auto calculated.

i try to do same thing by bring the table in a vb 2008 form using a datagrid view. when i run the application i can just enter the two values(num1 and num2) in the datagrid but the sum is not calculated despite pressing enter or tab and also the data entered is not saved.

any help

View 8 Replies View Related

Binding Multiple Sources To Datagridview

May 20, 2008

Hello, I have a datagridview setup right now to display data from one table in my database. However, I am going to need it to pull certain columns from certain tables and put them all into one datagrid. The three tables are demographics, financial, and procedures. Can someone give me an example on how I'd go about doing this? I'm using vb.net.

The procedures table is a list of options that will be displayed in a combo box, depending on the option selected, other cells in the datagrid will be filled with certain data, this data is in the procedures table as well. All of this data will be alongside a customer id located in the demographics table, and will all be recorded into the financial table.

View 1 Replies View Related

How To Display Data Retrieved In DataGridView Using SQL With Vb.net?

Feb 27, 2008

hi, could anyone tell me how to display data retrieved using sql in DataGridView?

View 6 Replies View Related

Populating DataGridView With Data From Two Tables?

Oct 11, 2007

I am sorry for asking such a broad question, but I have been working on this and from what I can gather it can be done. My problem is that much of it has gone right over my head and I am getting more confused the more I read... I'm really, really confused...

Basically, I have a dataGridView that is populated with a number of fields from Table1 (ID, NameID, Status, Phone, Notes). This works fine, BUT I would like to access Table2 and have, where ID in Table2 = NameID in Table1, it load the First Name & Last Name into the dataGridView. I am able to load the information from Table 2 like so: SELECT NameFirst + ' ' + NameLast from Table2", but I can't get both Tables to work correctly.

I would like the dataGridView to be layed out like this:

ID NameID Name (NameFirst + NameLast) Status Phone Notes

I can't for the life of me understand or get this to work (Or for that matter even understand what I am trying to do...

Also, I am using Access 2007.

I would greatly appreciate some help, and possibly some explanation in laymans terms so that I might be able to understand this. I have read a lot about this, but for whatever reason it is just soooooo over my head that I can't follow it whatsoever.

Here is the code as it stands now:

//Populate the DataGridView
string conString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Environment.CurrentDirectory + @"DB.accdb;Jet OLEDBatabase Password=MyPassword;";

// create and open the connection
OleDbConnection conn = new OleDbConnection(conString);
OleDbCommand command = new OleDbCommand();
command = conn.CreateCommand();

// create the DataSet
DataSet ds = new DataSet();

// run the query
command.CommandText = "SELECT ID AS [#], NameID AS [Name], Status AS [Status], Phone AS [Phone], Notes AS [Notes] FROM Table1 WHERE ID = " + textBox13.Text + ";";
OleDbDataAdapter adapter = new OleDbDataAdapter();
adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);

// close the connection
conn.Close();

bindingSource1.DataSource = ds.Tables[0];

dataGridView1.DataSource = bindingSource1;

// set the size of the dataGridView Columns
this.dataGridView1.Columns[0].Width = 10;
this.dataGridView1.Columns[1].Width = 100;
this.dataGridView1.Columns[2].Width = 100;
this.dataGridView1.Columns[3].Width = 100;
this.dataGridView1.Columns[4].Width = 176;

Any help and information is greatly appreciated.

Thanks Again,

View 5 Replies View Related

How Do I Insert Values Into CE From A DataGridView Row/rows?

Mar 19, 2007

 

Hi all...  can someone tell me why this does not work and how to make it work????

 SELECT     SQLkey, CreateDateTime, Alias, PropDNumb, PropDRevNumb, PropDItem, PropDMfg, PropDCat, PropDList, PropDCost, PropDGMDollar, PropDGM,
                      PropDSellPrice, PropDXSellPrice, PropDItemTotal, PropDShipQty, PropDStatus, create_timestamp, update_timestamp, update_originator_id,
                      create_date
FROM         ProposalDetail 
INSERT INTO temp
(
SQLKey, CreateDateTime, Alias, PropDNumb, PropDRevNumb, PropDItem, PropDMfg, PropDCat, PropDList,
PropDCost, PropDGMDollar, PropDGM, PropDSellPrice, PropDXSellPrice, PropDItemTotal, PropDShipQty, PropDStatus,
create_timestamp, update_timestamp,update_originator_id, create_date
)
VALUES
(
'1', '3/20/2007 8:13:10 AM', 'SomeUser', 'b1', '4', '0761046', 'APP', 'Miscellaneous Options',
'54.000', '27.00', '27.00', '50.00', '54.00', '54.00', '54.00', '1', 'Active', '3/20/2007 8:13:10 AM', '3/20/2007 8:13:10 AM', '0',
 '3/20/2007 8:13:10 AM'
)
WHERE     (PropDNumb = 'b1') AND (PropDRevNumb = '1')

 

Thanks a ton!

View 1 Replies View Related

Select The CheckBox Inside The DataGridView

Feb 29, 2008

Hi,

Can anybody help me fetch "True" & "False" value from a CheckBox inside a DataGridView row.

I tried the following code:-

But the cell.Selected doesnot take the correct value.


objGrid = (System.Windows.Forms.DataGridView)controlObj[0];

foreach (DataGridViewRow row in objGrid.Rows)

{

DataGridViewCheckBoxCell cell = row.Cells[0] as DataGridViewCheckBoxCell;



if (cell.Value != cell.FalseValue)



{

if (cell.Selected == true)

{

///Some Code;
}

}



}


Kindly Help ASAP
Thanks

View 4 Replies View Related

Does A User Have To Have SQL Server Installed In Order For Windows Form To Connect To SQL 2005 Express DB

Apr 23, 2008

Hello,

I am creating a windows application that is not going to be used in a controlled environment like a LAN or some other network, so I want to include a local database in the install of this app. Ideally, I would like to use SQL 2005 Express like you would MSDE or Access, but I am not sure if the user must have SQL Server installed on their machine in order for this to work and I don't have a machine without it to test on.

Any help on this is greatly appreciated.

Thanks,
Derek

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved