Problem With Saving Data In SQL Server

Nov 6, 2007

Hi,

         I have a problem. The thing is that when I enter the values in a text boxes like evendate.text = "02/11/07" and desc.text="hello how r u" then I click on Save Button and its save in the SQL DATABASE but after this if I click on Refresh Button every time from the internet Explorer its automatically again save the data in the database although I have empty the textboxes.

 The code is below:

<script runat="server">
 
 sub SaveEvent(sender as object, e as EventArgs)
     
   dim con as new SQLConnection("server=london-home; Database=tony; uid=rashid2; pwd=test; ")

      dim cmd as new SQLCommand("insert into events values('" & desc.text & "','" & DateTime.Parse(eventdate.text) & "')",con)
    
      con.open()
 
  cmd.executenonquery()
 
 con.close()
 clearform()
 display()
  
  end sub
 
  sub display()
 
    dim con as new SQLConnection("server=london-home; Database=tony; uid=rashid2; pwd=test; ")
    dim cmd as new SQLCommand("select * from events",con)
    
  con.open()
  
  dim SDR as SQLDataReader
  SDR = cmd.ExecuteReader()
 
 
  if SDR.HasRows = true then
     ViewEvents.DataSource = SDR
     ViewEvents.DataBind()
 
  end if
 
  con.close()
 
 
  end sub
 
  sub clearform()
    eventdate.text=""
 desc.text=""
   
  end sub
 
  sub Reset(sender as object, e as EventArgs)
    clearform()
 
   end sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>


<style type="text/css">

#display_prod{float:left;}

#prod{margin-top:0;}

</style>

</head>
<body>

<table border="1"  align="center" cellpadding="5" cellspacing="0">
<tr>
<td valign="top">

<form  id="prod" runat="server" enctype="multipart/form-data">
<table id="display_prod" width="554" border="1" cellspacing="0" cellpadding="0" align="left" height="400">
  <tr valign="top" height="20">
    <td>&nbsp;</td>
    <td>
       <table border="1" align="center" cellpadding="10" cellspacing="0">
        <tr>
        <td>PRODUCTS DESCRIPTION <asp:Label runat="server" ID="lbl"></asp:Label></td>
        </tr>
       </table>
      </td>
      </tr>
        
      <tr valign="top">
       <td> 
       <table align="left" id="menu" width="150" border="1" cellpadding="0" cellspacing="0">
        <tr align="center">
       
          <td><a href="home.aspx">Main</a></td>
        </tr>
        <tr align="center">
          <td><a href="Events.aspx">Change Password</a></td>
        </tr>
        <tr align="center">
          <td><a href="events.aspx">Events</a></td>
        </tr> 
        </table>
      </td>
     
      <td align="left">      
        <table width="390" border="1" cellpadding="0" cellspacing="0">
         <tr>
           <td width="100" >Enter Date :</td>
           <td width="243" ><asp:TextBox runat="server" ID="eventdate" BackColor="#FFFFFF" Width="100"></asp:TextBox> mm/dd/yy</td>      
         </tr>
         <tr>
           <td>Description :</td>
           <td><asp:TextBox runat="server" ID="desc" TextMode="MultiLine" Columns="20" Rows="3" BackColor="#FFFFFF" MaxLength="200"></asp:TextBox> max 200</td>
         </tr>
         <tr>
           <td>&nbsp;</td>
           <td>
               <asp:Button runat="server" ID="btnsubmit" Text="Save" OnClick="SaveEvent"></asp:Button>
               <asp:Button runat="server" ID="btnreset" Text="Reset"></asp:Button>
           </td>
         </tr>
       </table>
  
       <table width="390" border="1" align="left" cellpadding="0" cellspacing="0">
         <tr>
           <td>
              <asp:DataGrid runat="server" ID="ViewEvents" AutoGenerateColumns="false">
                <columns>
                  <asp:TemplateColumn>
                    <itemtemplate>
                       <table id="tt" border="1" cellpadding="5" cellspacing="0">
                        <tr>
                          <td><asp:Label runat="server" ID="eventname" Text='<%#container.DataItem("event_name")%>' ></asp:Label></td>
                      
                           <td><asp:Label runat="server" ID="pdesc" Text='<%# trim(DataBinder.Eval(Container.DataItem,"event_date","{0:MM/dd/yyyy}")) %>' ></asp:Label></td>
                        </tr>
                    </table>
                  </itemtemplate>
              </asp:TemplateColumn>
           </columns>
     </asp:DataGrid>
   </td>
  </tr>
</table>
       </td>
  </tr>
 </table>

 

</form>

 


</td>
</tr>
</table>
</body>
</html>

View 2 Replies


ADVERTISEMENT

Data Conversion From String To Decimal When Saving Data To SQL Server 2005 Using An ADO Recordset

Feb 12, 2008

Hello,

I am wondering what conversion rules apply, when a string, which contains a number, is saved to a SQL Server 2005 into a column of type decimal.

This is the code I€™m using (C++):

CString cValue = "0.75"
_variant_t vtFieldValue;
vtFieldValue = _variant_t(cValue)
pRecordSet->Fields->Item["MyColumn"]->Value = vtFieldValue;

"pRecordSet" is an ADO recordset. The database column "MyColumn" is of type "decimal(19,10)".

The most important question for me is, if the regional settings of the database server or the regional settings of the client PC are considered during the conversion from the string to the decimal value. For example in standard French regional settings the "." would not be recognized as decimal separator.

I am also wondering if the language of the database instance, in which this data is saved, is considered during this conversion or any other settings of this database instance.

So my general question is: Does anybody know exactly what rules apply during the above mentioned conversion?

Thank you for your help.

Regards,
Volker

View 2 Replies View Related

HOw To Saving Data From SQL Server

Jun 4, 2007



Hi

I have only read ( select access) in a sql server database(2000). I am able to scripts the database.

Can any ony have any idea how to extract the data from database?

not the backup of db, i don't have the access.

No DTS to extract data into text file.

some thing like save the table with data?

I have more than 300 tables.



Thanks

sandipan

View 1 Replies View Related

Saving Data As Word In Sql Server 2005

Feb 20, 2008

 Hi all,         I have an requirement that, I want to save data getting from text boxes etc..,on button click the data should be saved in database and also the data must be saved as word document with a file name with in the same database table which i am saving the data..i hope it's clear... I reached upto saving the data under button click..but I stuck up in converting the data to word and saving the same data in server ..??how to convert page data into word and at the same time i want that doc file to save in a table in serverThanks & Regards,Vamsee. 

View 1 Replies View Related

Problem With Saving Data To SQL Server Mobile ?

Aug 29, 2007

Hi everybody there

i have a small problem with this code, it cann't save changes on Datatable to the database SQL Server Mobile ..

the execution work succesfully but without changes in the database !

here is the code, please try to help :





Code Snippet

#Region " << Declarations >> "

Dim objCon As New SqlCeConnection("Data source=Storage CardFull_Database.sdf")
Dim objDA As SqlCeDataAdapter
Dim objCmdBldr As SqlCeCommandBuilder
Dim objTB As New DataTable("MyTB")
Dim objBS As New BindingSource

#End Region

Private Sub frmDatabase_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

objDA = New SqlCeDataAdapter("Select * From MyTB", objCon)
objDA.MissingSchemaAction = MissingSchemaAction.AddWithKey

objTB.Clear()

objDA.Fill(objTB)
objBS.DataSource = objTB

End Sub

' Add New Record for example
Private Sub mnuAddNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAddNew.Click

If Not CType(objBS.Current, DataRowView).IsNew Then
objBS.AddNew()

Dim dRowView As DataRowView = objBS.Current
dRowView.BeginEdit()

dRowView("id") = 10
dRowView("name") = "Someone"

dRowView.EndEdit()
End If

' Calling Save Methode
mnuSave_Click(sender, e)

End Sub

' Save Values
Private Sub mnuSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click

objBS.EndEdit()
objCmdBldr = New SqlCeCommandBuilder(objDA)
objDA.Update(objTB)

End Sub

View 2 Replies View Related

Sampling Data Set Via Integration Services Data Flow For Data Mining Models Without Saving Training And Test Data Set?

Nov 24, 2006

Hi, all here,

Thank you very much for your kind attention.

I am wondering if it is possible to use SSIS to sample data set to training set and test set directly to my data mining models without saving them somewhere as occupying too much space? Really need guidance for that.

Thank you very much in advance for any help.

With best regards,

Yours sincerely,

View 5 Replies View Related

SQL Server Admin 2014 :: Structure Of Log Saving (for Data Mining)

May 12, 2015

We saved huge log data from user behaviour in our site .

But In data mining time , we saw that most of them cant use for data mining

What is the best practice about data gathering from user movement in site?

is there any best practice Template for this ?

View 0 Replies View Related

Automating A Query And The Saving Saving Of Subsequent Results

Dec 13, 2007

Hi Guys,

I am trying to automate a basic task using SQL Server 2005 Express.

Currently I have a query script that I run and then save the results as a CSV file. I need to do this on a daily basis and so I am looking to find out how best to go about this. There are a multitude of third party tools that claim to be able to do this - can anyone recommend this or enlighten me of the best way to set up this automation.

All ideas gratefully received!

View 1 Replies View Related

Saving Cumulative Data Or Something Like That :)

May 4, 2007

Hi,There are 3 tablesTable,TableDetails,TableDaily.With structureTABLE:TableID        UserID        Money----------        ----------        ----------(int)            (int)            (money)TABLEDETAILS:TableDetailsID    TableID        ItemID        PaidForItem    DayID----------               ----------        ----------        ----------           ----------(int)                   (int)             (int)            (money)         (int)TABLEDAILY:TableDailyID    TableID        PaidForItem    Money        Total                                 Change----------            ----------        ----------            ----------        ----------                              ----------(int)                (int)             (money)          (money)      (PaidForItem + Money)       (money)"Table"    holds id for user and his money amount, which changes during time. "TableDetails" holds data about items user bought, amount paid for them and dayid which relates to one particular day."TableDaily" holds history. I do not know how to update this table.I created job whish runs stored procedure. This procedure sums "PaidForItem" using group by TableID and WHERE DAYID = '11'.Problem is with Change column. This column sould hold difference between today's Total and previous one etc.Current procedure looks like this:INSERT INTO    TableDaily        (TableID, PaidForItem, Money, DayID)SELECT        TableDetails.TableID,                     SUM(PaidForItem) AS PaidForItem,                     Table.Money,                    (SELECT    DayID                    FROM    Days                    WHERE  (Aktive = 1)) AS DayIDFROM          TableDetails INNER JOIN                    Table ON TableDetails.TableID = Table.TableID GROUP BY    TableDetails.TableID, Table.Money

View 3 Replies View Related

Saving Data To Another Table

Jun 14, 2007

Hi
I’m making a very primitive shopping cart. I’ve created a table containing a list of products and using an SQLdataSource with a GridView I’ve got the products displayed – simple.
What I now need is to add a button with an Insert command, but the SQL needs to add a row of data to a different table – tblShoppingBasket. I’ve tried adding in the insert command and changing the SQL but it doesn’t add a new record, although is also doesn’t through and error.
The second part of the problem is need to pass the productID from the row they selected (pressed the button that triggered the insert command) and add this to the shoppingBasket table via the insert SQL.
I’d really be grateful for any help (code below).
ThanksRichard
<asp:SqlDataSource ID="SqlDataSource_GenralProducts" runat="server" ConnectionString="<%$ ConnectionStrings:AquilaConnectionString %>"
SelectCommand="SELECT * FROM [tblProducts] WHERE ([productAgeGroup] = @productAgeGroup)"
InsertCommand="INSERT INTO [tblShoppingBasket] ([userID], [productID]) VALUES (@userID, @productID)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="productAgeGroup" Type="Int32" />
</SelectParameters>
<InsertParameters>
<asp:Parameter Name="userID" Type="Object" DefaultValue="123"/>
<asp:Parameter Name="productID" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" DataKeyNames="productsID"
DataSourceID="SqlDataSource_GenralProducts">
<Columns>
<asp:ImageField DataImageUrlField="productThumbNail" DataImageUrlFormatString="../images/shop/thumbNails/{0}">
</asp:ImageField>
<asp:BoundField DataField="productLabel" HeaderText="Product:" SortExpression="productLabel" />
<asp:BoundField DataField="productDescription" HeaderText="Description:" SortExpression="productDescription" />
<asp:BoundField DataField="productCost" HeaderText="Cost:" SortExpression="productCost" />
<asp:ButtonField ButtonType="Button" CommandName="insert" Text="Add to Shopping Basket" />
</Columns>
</asp:GridView>

View 1 Replies View Related

Saving Data Into Database

Aug 8, 2007

Im using MS visual web developer. I have created a website and used the database they set up by using admin tools. One page requires the take the users comment and to save it into the database. I've tried a formview and connected it to the database which worked. the problem is i cannot save whatever the user types into the textbox. {insert query didnt work with this set up }INSERT INTO aspnet_Membership(Comment) VALUES ('CommentTextBox.Text') Error: cannot set userId or to null. and if i make it allow nulls its going to move on to the next column. I would appreciate some help please. Thank you in advance.

View 4 Replies View Related

Saving Data Into SQLServer

Nov 6, 2007

Hi,
     
Here is a structure of my table 
create table events( event_id integer primary key identity(1,1), event_name varchar(200), event_date datetime,)
Note: The event_id is a automacally and we don't need to insert record in this field.
for example
i have inserted 10 records in a table
then i deleted all records manually from sql server
but when again I save the record the event_id field shows started from 11 even the table was empty,
although it should be start from 1?
 

View 6 Replies View Related

Saving Data Into Two Tables

Jan 12, 2008

Hello all ...
 I am facing a problem in the evaluation form that I am working on ...
I have 3 textboxes which are
Trainee ID, Trainee Name and Trainee Department
I want the Trainee ID to be saved in the Evauaiton form , The trainee id is a foregin key in the Evaluation table in my SQL table, it is coming from the trainee table where the Trainee ID is primary key and it is incremneting ...
I want the same Trainee Id to be sent to both Trainee and evaluation table , but at the same time , i want whenever a user open the evaualtion form an id will be shown and it will be inccremented ...
 
Hope that is clear ...
 How I can solve this problem?
 

View 3 Replies View Related

Saving Data To A Database

Feb 15, 2006

Hi there,
I have a web page (Visual Studio 2005, Asp.net 2.0) that has a series of textboxes and dropdownlists on it.  I want people to be able to enter their information and click submit.  When they click the submit button I want their information to save to a Sql Server 2005 database.  I am having a lot of trouble finding any information on this topic.  If someone could give me some sample code I would really appreciate it. 
Thanks

View 2 Replies View Related

Saving And Retriving Data To SQL Db From FCKeditor

Dec 13, 2006

Hi Every one
I m using FCKeditor in my web application and my requirement is to create and edit documents in FCKeditor.
The problem is in  storing the data. it is not storing the data in the DB. its only stors some html code but it is incomplete.
Please some one Solve this problem

View 1 Replies View Related

Saving Data And Retrieving It From The Database

Sep 18, 2007

Heres my requirement from a financial analysis im doing...I have just calculated an industry averages on financial ratios...Now i wanna upload this industry average to the system...so that I can compare it to the individual companies' averages after calculating a particular company's average; meaning i wanna be able to call the industry average of a particular ratio (eg Current Ratio) after calculating a company's corresponding ratio...Is there a code fragment i can use for this ?? Thanks in advance...Adam 

View 1 Replies View Related

Saving As Csv File From Sql Data Base

Jun 20, 2007

HI every one,

I am pretty mcuh new to sql and I read all your previous replies..I jsut have my questions answered.If you can help me that would be great!

I can acces the date base using Server manager then retireve the data using the query .But now I need to convert that obtained the data into csv file n then save it into csv file.
IF you can help me out that would be great.

View 6 Replies View Related

Saving Data To SQL Data Base

Aug 14, 2007

Hi,I'm using the following code to open a data base and show it's contentin a Data Grid View----Code-----Imports System.Data.SqlClientPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.LoadDim conn As New SqlConnection("DataSource=./wideserver;Path="c:/cct.mdf";UserId=username;Password=Password;")Using (conn)conn.Open()Dim com As SqlCommand = conn.CreateCommand()Using (com)com.CommandType = CommandType.Textcom.CommandText = "Select * From users"Dim da As New SqlDataAdapter(com)Using (da)Dim dt As New DataTable("usertable")Using (dt)da.Fill(dt)Dim dgv As New DataGridView()dgv.Dock = DockStyle.Filldgv.DataSource = dtMe.Controls.Add(dgv)End UsingEnd UsingEnd UsingEnd UsingEnd Sub-----end code-----The following code allow me to see the table data in a Data Grid Viewbut now i want to save the changes in the table (after makingmodifications in the dgv)i use : dta.update(dt)but that don't work !!!!!!Any Help and thanks a lotOmar Abidwww.omarabid.uni.cc

View 2 Replies View Related

Saving Datetime Data In A Stored Procedure

May 23, 2007

Hello everyone  I have a stored procedure that I am trying to save datetime data to at the moment I can create a string that will output 25/05/2007 18:30 Does anyone know the best way to get this into the correct format for my SP parameter
cmdPublish.Parameters.Add(new SqlParameter("@datPublishDate", System.Data.SqlDbType.DateTime));
cmdPublish.Parameters["@datPublishDate"].Value =  ????
 Thanks
 
 

View 3 Replies View Related

Requesting It(PK) After Saving Data With Auto Prim.Key

May 26, 2006

Hi,

I have a page for saving a "home" data. As the page unloads I will
redirect the user to the page on which he can add the photos to this
"home".

Well I structured my photo adding page with first requesting the "homeID" which is an auto Integer (PK).
Because it's renaming the uploaded photos with the homeID and _01, _02...  

Because of that i need to send the user to the photo adding page with "response.redirect......aspx?homeID=.....

homeID=  ???

But I don't know how to get the homeID value, that the SQL Server automaticly selects for the data. As it is just saving it...


Thanks a lot.

View 1 Replies View Related

Saving Data Into A Table & Multiple Processors

Mar 10, 2000

Hello,

Yesterday I was looking to the processor usage in the Task Manager of Windows NT when a script of mine was running. The script was an InfoPump Script; which is a tool from the DecisionBase suite from CA (was previously owned by Platinum). This script contains SQL statements that select data from several tables and stores the result into another table. The SQL code used for this looks fine to me.
The query was running on a Compaq Proliant 5500 with 4 500 Mhz Xeon processors, 1 GB RAM, NT Server 4, SP 5, RAID 5. The SQL Server is configured to use all resources and SQL has normal priority on NT.
When the select part was running al four processors were used for about 75% and when the store happens only 1 processor is used for 100%.
Why is the store not spread over all four processors? It only uses one processor and it seems to be a bottleneck.

Stef

View 2 Replies View Related

Error For Sending(saving) Data To Database

Feb 22, 2007

Hi,I'm using VS2005 and I'm trying to link the C# windows form to MSSQL.I used BindingNavigator Control to read the data. After that I addsqlcommand and sqldataadapter to send the data to the database. Mycode is thissqlDataAdapter1. InsertCommand. CommandText ="INSERT INTO SUDENT (" +"S_ID, S_NAME, S_ADDRESS, S_PHONE" +") VALUES ('" +S_IDComboBox. Text + "', '" +S_NAMETextBox. Text + "', '" +S_ADDRESSTextBox. Text + "', '" +S_PHONETextBox. Text + "')";sqlDataAdapter1. InsertCommand. ExecuteNonQuery( );It gave me this error"NulleferenceExcept ion was Unhandled"and " Object refrence not set toan instance of an object" so I add this linesqlCommand1 = ("INSERT INTO STUDENT (S_ID,S_NAME, S_ADDRESS, S_PHONE)VALUES (@S_ID,@S_NAME, @S_ADDRESS, @S_PHONE) " ,sqlConnection1) ;Then it gave me some stupid error. By the way it didn't make a newobject of SqlCommand although I tired ....So can u help me to solve my problem ? Thank you

View 1 Replies View Related

Error Saving Binary Data To Sql Mobile

May 7, 2006

I have been trying to place a binary byte array into the sql server mobile 2005 database and continually get an error "The Identifier cannot be an empty string." when attempting to save this sql to the database:

"INSERT INTO KHZ_Company_Permissions ( PermissionID, CompanyID, StatusID, PluginTypeName, PermissionLevel, ChangeStamp, RecordState ) VALUES (1, 1, 1, 'Plugins.Approval.ApprovalList', 2, System.Byte[], 0)"

the byte array ChangeStamp is a timestamp datatype in the Sql Server Database and is pulled into a custom business object as the .net datatype Byte()

in the debugger, the byte array looks like it should as a timestamp comprised of 8 bytes with the values: 0,0,0,0,0,0,63,181 . but when i attempt to execute the sql statement, i get the sqlceexception "The Identifier cannot be an empty string." if i change the byte to a string and save it as an nvarchar, the value is preserved and i can then pass it back to compare it to the timestamp when synching up to the Sql Server Database later, but i would prefer to maintain the type as a binary datatype, and avoid the string conversion...

When i am creating the sqlstring (which i then run using a sqlcommand/nonquery) i add the binary data to the sqlstring by referencing the .tostring character ... do you think this may be what is causing the error, and if so, is the only way to insert binary data to a sql ce db by using sqlcecommand parameters?

i have found no information to assist with this error, any ideas are much appreciated

View 4 Replies View Related

Application Hangs When Saving Data After A Syncronization

Oct 5, 2007

Hi! I am developing a CF 2.0 application for WM 6.0. In the application I'm doing a replication between a Sql Server 2005 database and a Sql Server 2005 Compact Edition database. When I'm trying to syncronize the databases for the first time, e.g., creating a new database with AddSubscription(AddOption.CreateDatabase)I cannot do a save afterwards the synchronization procedure. The synchronization works just fine and I get the right data to my device and so, but when I try to a save, the database hangs doing the commit().

If I'm on the otherhand restarts the application and then do a ReinitializeSubscription(true), e.g., doesn't not create a new database with AddSubscription(AddOption.CreateDatabase), and calls Synchronize(), everything works just fine. Anyone who has an explanation of this? (I do a Dispose() each time).

View 1 Replies View Related

Saving Packages And Custom Component Data

Mar 14, 2007

I am looking for some advice regarding saving custom component data when saving packages.

For custom "properties", this is not an issue, as saving the package will save these properties. Howver, I also have information for each column (besides the properties that columns provides, like Name and DataType) that I need to save if a package were to be saved, and right now it does not save because I am using my own objects to store the data.

I am wondering as to how I can save this information. I have looked up on serialization, but I would like to know if there is another way besides serialization to save this inforamtion as I'd rather not save this to a seperate file.

Thanks

View 4 Replies View Related

Saving Some Data Despite A Rollback Transaction Command

Sep 12, 2007



I am working on reformating, cleaning, adding derived elements, etc... on data with no data validity checks on the front-end, source data. Its an incremental process where each month I add new data to the prior months' history. Sometimes the new monthly source data "surprises" me -- different values, different data definitons, etc. than expected.

I deal with these surprises by accumulating the fields/values that are unexpected after converting them to varchar with some explanatory language into a table [program_newdataprobs]

If there are any records in [program_newdataproblem] I rollback the transactions so the prior months' history remains unaltered. The problem is I then "lose" the contents of [program_newdataproblem] which I would like to hand to the source data people to troubleshoot.

I have tried the following:


Begin Transaction tran1

.... code that reformats data here
if (select count(*) from program_newdataproblem)>0

BEGIN



Begin Transaction tran2

select * into #t1 from program_newdataproblem

Commit Transaction tran2

Rollback Transaction tran1

insert into program_newdataproblem
Select * from #t1


END


This bombs because because #t1 no longer exits

Any way I can "keep" the data from program_newdataproblem when I Rollback the other transactions? (without having to store the history in separate tables that I can then access if new data errors occur)

Thanks,




View 3 Replies View Related

Data Conversion &&amp; Saving Takes Time

Jan 31, 2008

The following T-SQL code is run in a vb.net (2003) module.

I am acquiring data from an OPC server into an array of data type object. It is necessary to declare the array as an object for the OPC server to return data. The OPC returns the data in 15 mS.

I now need to save this data to a table in SQL 2005 running on a 2003 server.

The table for saving the data has already been created and saving the data is actually an 'update ... set ... where' statement.

The statement is
For i as short = 1 to itemCount

sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = " & itemValue(i) & " where TagName =' " & tagName(i)
sql_command.executeNonQuery
Next

The TagValue field datatype is decimal(18,6)
The itemValue(i) datatype is object / variant. The itemValue array contains 95% values of type Single and the rest are Integers.
The TagName datatype is varchar(50)
The tagName(i) datatype is string

When I run the loop (255 iterations) with the above query it takes 1500 mS.

If I force a conversion by changing the query to
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = Convert(decimal, " & itemValue(i) & ") where TagName =' " & tagName(i)
it takes 900 mS to execute for 255 iterations.


I tried one more variation
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = Convert(decimal(18,6), " & itemValue(i) & ") where TagName =' " & tagName(i)
which takes 1200 mS to execute for 255 iterations.

If I use the following code
dim tempValue as decimal = 123456789012.123456D
sql_command = "Update [IO Log].[dbo].[IO Log] Set TagValue = " & tempValue & " where TagName =' " & tagName(i)
it excutes in under 100 mS for 255 iterations.

There seems to be a problem during implicit / explicit conversion of type object/variant to decimal.
I need to save the data received from the OPC (255 tags) in under 150 mS.

Could somebody help?



View 18 Replies View Related

Error For Sending(saving) Data To Database

Feb 22, 2007

Hi,
I€™m using VS2005 and I€™m trying to link the C# windows form to MSSQL. I used BindingNavigator Control to read the data. After that I add sqlcommand and sqldataadapter to send the data to the database. My code is this

sqlDataAdapter1.InsertCommand.CommandText =
"INSERT INTO SUDENT (" +
"S_ID, S_NAME, S_ADDRESS, S_PHONE" +
") VALUES ('" +
S_IDComboBox.Text + "', '" +
S_NAMETextBox.Text + "', '" +
S_ADDRESSTextBox.Text + "', '" +
S_PHONETextBox.Text + "')";

sqlDataAdapter1.InsertCommand.ExecuteNonQuery();

It gave me this error
€śNulleferenceException was Unhandled€?and €ś Object refrence not set to an instance of an object€? so I add this line

sqlCommand1 = ("INSERT INTO STUDENT (S_ID,S_NAME,S_ADDRESS,S_PHONE) VALUES (@S_ID,@S_NAME,@S_ADDRESS,@S_PHONE)" ,sqlConnection1);

Then it gave me some stupid error. By the way it didn€™t make a new object of SqlCommand although I tried €¦.

So can u help me to solve my problem ? Thank you

View 4 Replies View Related

DB Engine :: Saving Data From One Textbox To 2 Tables?

Oct 1, 2015

i need to display variables from one textbox to 2 or more tables in database, how do i do that?

View 2 Replies View Related

Saving Data To A Database File Via Simple Form

Nov 2, 2007

Hi,
I am designing a site using Visual Web Developer, CSharp and Sql server Express.
One the contact page I want to put a form that allows users to enter details about
themselves. On clicking the button this will be stored in the database under a table
called subscribers. The form will have, name, address, telephone, email fields etc.
With the email addresses from the visitors I want to be able to keep them in
a newsletter section or similar which is automated so they recevie emails from time to time
Could somebody suggest a tutorial which shows how to complete this process
using c sharp and sql.
 
Thanks for you time
 
Prontonet
 

View 2 Replies View Related

C# Code For Saving Data From Excel To Mssql Database

Dec 30, 2004

Hello everyone,

I am trying to find some code or documentation that I can use to create a web page that will save data from an excel file to a mssql database

View 5 Replies View Related

Saving DTS Package In Meta Data Services Error

Apr 27, 2004

I am running SQL Server 2000 SP3 and I am trying to save a DTS package into Meta Data Services and I am receiving the following "Package Error"

Error Source: Microsoft Data Transformation Services (DTS) Package
Error Description: General Error -2147217355 (80041035).

I have searched for this error and I cannot find anything related to it. Also, I saw some of the comments about right clicking "Data Transformation Services" and checking the box for allow save to Meta Data Services, however, I do not see that checkbox to allow for this. Has anyone else had this problem and resolved it? I'm beginning to get very frustrated with it.

View 1 Replies View Related

SQL 2012 :: Data Collection And Daylight Saving Time

Oct 26, 2015

Last weekend many of our severs had a failed job "collection_set_3_upload". The error that occured is: "Violation of PRIMARY KEY constraint 'PK_ active_ sessions_ and_requests'. Cannot insert duplicate key in object 'snapshots.active_sessions_and_requests'. The duplicate key value is (2824333, 2015-10-25 02:54:49.7630000 +02:00, 1)."Last weekend we happened to go from summer time to winter time. i.e. the clock passed 02:00 - 3:00 two times during this night.

I.e. there is a bug in the Data Collector component that collects data for the Management Data Warehouse: it uses local time instead of UTC. I've created a Connect item to report it to Microsoft.URL...how do you get your process running again? the job will no longer run because it will every 5 minutes keep on trying to upload the conflicting data for the 2nd 2:00 - 3:00 period. I've only found one solution: get rid of all data collected but not yet uploaded.

You do this by stopping the Collection set (in SSMS go to Object Explorer -> <the server you want to fix> -> Management -> Data Collection -> System Data Collection Sets. Right click "Query Statistics" and select "Stop Data Collection Set").Then you delete the cached results from the sql server machine's harddisk. These cached results are in files located in a Temp folder on the sql machine itself, inside the AppData folder for the service account SQL Server Agent is running under. Usually it will be something like: c:Users<sql agent service account>AppDataLocalTemp.

Inside this folder delete all files that have 'QueryActivity' in their name. You'll loose all data collected since the start of wintertime, but at least your data collection process will work again.After this you can start the Collection set again by right clicking it and select "Start Data Collection Set". Every 5 minutes the data will be summarised and uploaded into your management data warehouse.

Posting Data Etiquette - Jeff Moden
Posting Performance Based Questions - Gail Shaw
Hidden RBAR - Jeff Moden
Cross Tabs and Pivots - Jeff Moden
Catch-all queries - Gail Shaw

View 0 Replies View Related







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