How To Store Duration In Database?
Nov 27, 2007
Hi all,
I want to find working duration between two datetimes in c#.
i'm using following code...
DateTime starttime = Convert.ToDateTime(Session["StartTime"]);
DateTime endtime = DateTime.Now;
TimeSpan duration = endtime - starttime;
DateTime period = new DateTime(duration.Ticks);
i want to store this duration in database through stored procedure, i've give datetime datatype to duration but it is giving error in conversion of TimeSpan to DateTime..
Please help... Thanks
View 1 Replies
ADVERTISEMENT
Jun 4, 2015
I have the following SQL query
SELECT
[Req_ID]
,[Service_Name]
,[Req_Started_Date]
,[Task_Name]
,[Task_Status]
,[Performer_Full_Name]
[code]....
Which works fine, but what I need to calculate the total duration of a request based on the duration of the tasks completed in the request based on Req_ID. I would like to use the CASE statement I have to determine the SLA_Mins for each task and add them together to get total request SLA_Mins.
Below is the create table schema and data
GO
/****** Object: Table [dbo].[MidrangeOtherSourceControl] Script Date: 06/03/2015 18:13:15 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[MidrangeOtherSourceControl](
[Req_ID] [float] NULL,
[Service_Name] [nvarchar](255) NULL,
[code]....
View 9 Replies
View Related
May 16, 2000
I need to grant select, insert, update, and delete permission to an object residing in Database "X" from a store procedure in database "Y". I have already tried USE database statement. Any suggestion.
Thanks
Maroof Khan
View 1 Replies
View Related
Aug 13, 2006
How to store an image on to my SQL database from the web form? Please guide me through. Thank you.
View 1 Replies
View Related
Aug 22, 2006
Hi everyone,
I'm just using TEXTBOX control to save data into my DB. My question is, if I have multiple lines of sentences, it does not store as what it looks like. For example;
Hello, Mike
It stores into the database as "Hello, Mike" and if I read from the database, it does not have seperate lines and shows it like this;
Hello, Mike
How can I store the contents into database and make the contents as original? (Sorry for the poor English, but I hope you understand it.)
View 2 Replies
View Related
Aug 24, 2006
mo tu we th fr _______________________morning |___|____|_____|__X__|____|afternoon |___|_X__|_X__|__X__|____| evening |___|____|_X __|__X__|____|Hey guys, i have to store the values of the above table into the database however i have know idea how to design the table. Could you guys give me some suggestion.Currently i come up with the below solution.OpenTime---------------OpenTimeIDDateIDTimeIDDate------------DateIDDateNameTime-----------TimeIDTimeName
View 1 Replies
View Related
Dec 13, 2006
how can I store a filename in the database, i have some GIF files which i want to show up on report, how can i specify those filename with a path in the database.
i tried manually entering the path c:Dataimages.gif but it didnt work. Can someone pls tell me how to do it.
Regards,
Karen
View 5 Replies
View Related
May 8, 2007
please tell the steps
How to store File in SQL DataBase
View 1 Replies
View Related
Oct 12, 2007
Hi
Anyone Knows
I want to store SQL 2005 Existing Database into SQL Server Through .Net.if i give Database Name in .Net and that Database automatically stored in SQL Server 2005.P(including that Existing Database Tables and Stored Procedures).Please Help me.
Tamil
View 2 Replies
View Related
Dec 14, 2005
I have a problem I 'get stuck on it. i hope someone can help me.
I have a SQLServer table with an ID-field with a primary key and identity on it, and a couple of other fields with defaultvalue "" and NOT nullable
When i like to update an record in an formview of ASP 2.0 and fill in all fields everything is updated and everything goes fine
but
when I leave one field blank then I get the message 'can not enter null value in column X'
even when I place in the Updateparameter in my code
<asp:Parameter Name="Name" DefaultValue="" /> ASP tries to update an Null value
when i place an space as default value like
<asp:Parameter Name="Name" DefaultValue=" " />
everything goes fine exept there is an space in my database.
How can I update my record, and leave some textboxes emtpy AND where my fields are NOT nullable
I'm getting desparate of this.
make my fields nullable is not an option because this is a 'customerswish'
Please help
View 2 Replies
View Related
Feb 26, 2006
I want to store IMAGE into Database So can any one tell me what's the command for that ?
like my image name is hello.jsp
command means the query like ( Select * from tableNAme )
Like thins pl help me & tell me What datatype should i use for that ?
Thaks for your help in advance
Have a Good Day
Harsh
View 1 Replies
View Related
Sep 5, 2006
How do you setup your database to allow storing languages such as Arabic?
View 10 Replies
View Related
Jul 12, 2007
Hi
I want to know how do we store null in the database
i know Null is unkown value
but it has to be something so the SQL server can know its null ( computer only knows 0s and 1s )
is it pointers and null does not have a pointer?
or do we store something physically?
an example : we have string(varchar) column that has this value in it "Joey Tribbiani" that means in the hard disk we will see 14 bytes "Joey Tribbiani" in there, if we changed the value to "Monika" the 14 bytes will be replaced by 5 bytes "Monika", if we changed to empty strike then we will have 0 bytes ""
now if changed it to become NULL what is going to happen to the hard disk, what is going to be in there physically??
may anyone help me in this?
many thanks
View 3 Replies
View Related
May 8, 2006
hi everybody,can anybody help me out by telling me how could I store images in a database, and how to insert new images at run time to a database and thanks
View 1 Replies
View Related
Aug 23, 2006
update Food set FoodName = ' æ??ä»?' where ID = 100
in database as ??
View 10 Replies
View Related
Aug 11, 2006
Hello,
I am working on a project. We do not have a DBA, so I am performing some of these tasks.
I recently created a new database with about 10 tables. I have set up the key and primary key relationships between the data files.
How do I save the database through differenct stages of it's evolution? Suppose I populate the database, but later on decide that I we need to re-start from scratch and go back to the new database I created that is not populated. How do I save different versions of a database through it's evolution/progression?
Thanks in advance, Bill
View 1 Replies
View Related
Jan 14, 2007
Hello All,
My question is how to store images in a database table (in SQL Server), and how to retrieve them?...
Thanks,
View 2 Replies
View Related
Apr 11, 2007
Hi FriendsCan anyone tell me how to store uploaded files from the user to the SQL database and later give an option of downloading the file probably in the form of a GridView control. How do we write code to allow the user to download the uploaded files. I have written code to upload and store the files into a folder, however, I'm not able to collect data from the folder later and the folder is only accessible offline using the server system which I do not want to happen. Can anyone help me with this?Thanks
View 1 Replies
View Related
Oct 11, 2007
hello all, I have a multi line textbox and want to store the content of the textbox to a database. I want to preserve the linefeeds so that I display the message as it is typed by retrieving it. Can anyone please explain how to store the linefeeds to the database. Once i store the linefeeds to the database, I can restore them using the Replace("","<br/>) method. But I can't figure out how to store the 's in the database in the first place. Thanx in advance
View 2 Replies
View Related
Dec 29, 2007
Hi i am creating a web page which will return the results of products, the store name and the distance of the store from the postcode which the user has put into a text box. My first question is how would my database structure look, below is what it looks like at the moment;
Company; companyID, companyName, companyAddressLine1, companyAddressLine2, companyPostcode.
and
Products; productID, productName, companyID, price.
In order to achieve the proximity search how would i alter the "Company" table, as in what columns will need to be added or removed, thank you.
View 3 Replies
View Related
Mar 19, 2008
in my local sql server,i want one of my databases store date in dd-mm-yy format,currently it stored in mm-dd-yy format,and i want this format specific to this database only,it should not affect on my other database.how can i get this??
View 5 Replies
View Related
Mar 22, 2008
how to use class iDataReader's function getbytes(...............) to read binary data?
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlClient;using System.Data.Common;using System.IO;
public partial class uploadFileToDatabase : System.Web.UI.Page{ string strUser; protected void Page_Load(object sender, EventArgs e) { strUser=Request.QueryString["download"]; if(strUser!=null) { string strConn="Data Source=hao-pc;Initial Catalog=simpleBBS;Persist Security Info=True;User ID=sa;Password=123;Pooling=False"; SqlDataAdapter sda=new SqlDataAdapter(); DbProviderFactory dbProviderFactory=DbProviderFactories.GetFactory("System.Data.SqlClient"); DbConnection dbConn=dbProviderFactory.CreateConnection(); dbConn.ConnectionString=strConn; dbConn.Open(); DbCommand dbComm=dbProviderFactory.CreateCommand(); dbComm.Connection=dbConn; dbComm.CommandText="select * from userFiles2 where fileisn='"+strUser+"'"; IDataReader myReader=dbComm.ExecuteReader(); int strFileLen=0; if(myReader.Read()) { strFileLen=Convert.ToInt32(myReader.GetString(3)); FileStream afs; string fPath; fPath = Server.MapPath(Request.ApplicationPath) + "\upLoadFiles\" + myReader.GetString(1); afs = new FileStream(fPath, FileMode.OpenOrCreate, FileAccess.Write); Byte[] filedata = new Byte[strFileLen]; afs.Write(filedata, 0, strFileLen); BinaryWriter abw; int iBufferSize=1000; Byte[] outbyte=new Byte[iBufferSize-1]; long retval; long starIndex=0; abw=new BinaryWriter(afs); starIndex=0; int itemNum=4; retval=myReader.GetBytes(itemNum,starIndex,outbyte,0,iBufferSize); //when i store large data into a file it display an error such as "Buffer offset '0' plus the bytes '82452' is greater than the length of the passed in buffer. abw.Write(outbyte); starIndex+=iBufferSize; retval=myReader.GetBytes(itemNum,starIndex,outbyte,0,iBufferSize); } abw.Write(outbyte); abw.Flush(); abw.Close(); afs.Close(); myReader.Close(); dbComm.Dispose(); } } } protected void Button1_Click(object sender, EventArgs e) { string strFileName; string strFileType; int strFileLen; Random ran=new Random(); string strFileISN=DateTime.Now.ToString("yyyyMMddhhmmss")+ran.Next(0,999); if(FileUpload1.PostedFile.FileName!=null) { strFileName=FileUpload1.PostedFile.FileName; strFileType=strFileName.Substring(strFileName.LastIndexOf(".")+1); strFileName=strFileName.Substring(strFileName.LastIndexOf("\")+1); strFileLen=FileUpload1.PostedFile.ContentLength; string strConn="Data Source=hao-pc;Initial Catalog=simpleBBS;Persist Security Info=True;User ID=sa;Password=123;Pooling=False"; SqlDataAdapter sda=new SqlDataAdapter(); DbProviderFactory dbProviderFactory=DbProviderFactories.GetFactory("System.Data.SqlClient"); DbConnection dbConn=dbProviderFactory.CreateConnection(); dbConn.ConnectionString=strConn; dbConn.Open(); DbCommand dbComm=dbProviderFactory.CreateCommand(); dbComm.Connection=dbConn; string dateTime=DateTime.Now.ToString(); Stream fs=FileUpload1.PostedFile.InputStream; Byte[] filedata=new Byte[strFileLen]; fs.Read(filedata,0,strFileLen); dbComm.CommandText="insert into userFiles2 (fileisn,filename,filetype,filesize,filecontent,uploadTime) values (@fileisn,@filename,@filetype,@filesize,@filecontent,@uploadTime)"; dbComm.Parameters.Add(new SqlParameter("@fileisn", (object)strFileISN)); dbComm.Parameters.Add(new SqlParameter("@filename",(object)strFileName)); dbComm.Parameters.Add(new SqlParameter("@filetype",(object)strFileType)); dbComm.Parameters.Add(new SqlParameter("@filesize",(object)strFileLen.ToString())); dbComm.Parameters.Add(new SqlParameter("@filecontent",(object)filedata)); dbComm.Parameters.Add(new SqlParameter("@uploadTime",(object)dateTime)); dbComm.ExecuteNonQuery(); fs.Close(); dbConn.Close(); dbComm.Dispose(); dbConn.Close(); } } }
View 3 Replies
View Related
Mar 23, 2008
hi,
i would like to store images in my database and retirve them aswell. i have looked at examples on the net but i am finding it hard to follow and undertsand them, can anyone please give me adivse on how i can do this. i have alrady created my table in my database which has 4 fields pictureID, pictureContent, pictureType and pictureSize but i dont know where to go on from here. i want to do it in vb aswell.
please any help and advise would be much appreciated as i am stuck,
thank you
View 20 Replies
View Related
Apr 24, 2008
Hi
I have a asp:FileUpload conponent that I am trying to use to retrieve a picture file from the clients pc and store it in a SQL database.
The table is called PropertyImage and it contains the following fields:
imgID (type = int - autoincrement); imgData (type = Image); imgTitle (type = VarChar); imgType (type = VarChar); imgLength (type = BigInt);
I have a button (Button1) which when clicked calls Button1_Click()
--------------------------------------------------protected void Button1_Click(object sender, EventArgs e)
{byte[] fileData = null;
Boolean status = false;if (FileUpload1 != null)
{
// Make sure the file has data.if ((FileUpload1.PostedFile != null) && (FileUpload1.PostedFile.ContentLength > 0))
{
// Get the filename.string fn = System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName);
try
{
// Access the file stream and begin the upload. Store the file in a memory byte array.Stream MyStream = FileUpload1.PostedFile.InputStream;
long iLength = MyStream.Length;fileData = new byte[(int)MyStream.Length];MyStream.Read(fileData, 0, (int)MyStream.Length);
MyStream.Close();
}catch (Exception ex)
{ }
}
}SqlConnection connection = new SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\heidihomes.mdf;Integrated Security=True;User Instance=True");
try
{
connection.Open();SqlCommand sqlCmd = new SqlCommand("INSERT INTO PropertyImage (imgData, imgaTitle, imgType, imgLength) VALUES(@data,@title,@type,@length)");
SqlParameter param = new SqlParameter();
// String connectionString = new SqlConnection(sqlCmd, connection);
param = new SqlParameter("@data", SqlDbType.Image);
param.Value = fileData;
sqlCmd.Parameters.Add(param);param = new SqlParameter("@title", SqlDbType.VarChar);
param.Value = fileData;
sqlCmd.Parameters.Add(param);param = new SqlParameter("@type", SqlDbType.VarChar);
param.Value = fileData;
sqlCmd.Parameters.Add(param);param = new SqlParameter("@length", SqlDbType.BigInt);
param.Value = fileData;
sqlCmd.Parameters.Add(param);
sqlCmd.ExecuteNonQuery();
connection.Close();status = true;
}catch (Exception ex){ }if (status)
{
UploadStatus.Text = "File Uploaded Successfully";Server.Transfer("Admin_PropertyView.aspx");
}
else
{UploadStatus.Text = "Uploaded Failed";
}
}
}
--------------------------------------------------
But when I click on the button, nothing happens.
Please could someone help me out here. I have tried this a few times and still haven't come right.
Also, if there is something else wrong with the code, please let me know.
Thanking you in advance.
View 9 Replies
View Related
Feb 1, 2005
Hi,
How to insert image into database?Anyone know how to do this, please kindly lead me and give me the solution to solve this problem. Thanks a lot.
p@ywen
View 5 Replies
View Related
Mar 10, 2005
hi,friends
i need your help.
i want to store a date into sqlserver database using stored procedure.
when i run app.
it will give this error.......
----------------------------------
Server Error in '/aspnet/espms' Application.
--------------------------------------------------------------------------------
String was not recognized as a valid DateTime.
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.FormatException: String was not recognized as a valid DateTime.
Source Error:
Line 349: cmd.Parameters(6).Value = CType(ddldeltype.SelectedValue, Integer)
Line 350: cmd.Parameters(7).Value = txtshipnm.Text
Line 351: If cmd.ExecuteNonQuery Then
Line 352: add = True
Line 353: Else
Source File: c:inetpubwwwrootaspnetespmsprchspur_det_add.aspx.vb Line: 351
------------------------------
my source code is .....
---------------------------------------
- - - -
- - - -
cmd.CommandText = "add_v_dispatch_det"
cmd.Connection = conn
cmd.CommandType = CommandType.StoredProcedure
cmdbld.DeriveParameters(cmd)
cmd.Parameters(1).Value = prid
cmd.Parameters(2).Value = cd(1)
cmd.Parameters(3).Value = cd(3)
cmd.Parameters(4).Value = txtdeldt.text '(dd/MM/yyyy) i.e. "20/12/2005"
cmd.Parameters(5).Value = txtrecdt.text '(dd/MM/yyyy) i.e. "20/12/2005"
cmd.Parameters(6).Value =CType(ddldeltype.SelectedValue, Integer)
cmd.Parameters(7).Value =CType(ddldeltype.SelectedValue, Integer)
- - - -
- - - -
my stored procedure is ...
------------
CREATE PROCEDURE add_v_dispatch_det
@purid char(8),
@prcd char(20),
@qty varchar(5),
@deldt datetime,
@recdt datetime,
@deltype int,
@shipnm char(50)
AS
insert into vend_dispatch_detail
values(
@purid,
@prcd,
@qty,
@deldt,
@recdt,
@deltype,
@shipnm
)
GO
--------
what should i do?
plz give any solution.
thanks in advance.
it's urgent
View 1 Replies
View Related
Apr 20, 2005
Hi everyone,
I am currently reading ASP.NET unleashed and practising few examples. The following code converts a user's text into a symmetric encryption:
'nd: define keys
Const DESKey As String = "ABCDEFGH"
Const DESIV As String = "HGFEDCBA"
'nd: convert string to byte array
Function convert2ByteArray(ByVal strInput As String) As Byte()
Dim intCounter As Integer
Dim arrChar As Char()
arrChar = strInput.ToCharArray
Dim arrByte(arrChar.Length - 1) As Byte
For intCounter = 0 To arrByte.Length - 1
arrByte(intCounter) = Convert.ToByte(arrChar(intCounter))
Next
Return arrByte
End Function
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
Dim arrDESKey As Byte()
Dim arrDESIV As Byte()
Dim arrInput As Byte()
Dim objFileStream As FileStream
Dim objDES As DESCryptoServiceProvider
Dim objEncryptor As ICryptoTransform
Dim objCryptoStream As CryptoStream
'convert string to bytes
arrDESKey = convert2ByteArray(DESKey)
arrDESIV = convert2ByteArray(DESIV)
arrInput = convert2ByteArray(txtInput.Text)
objDES = New DESCryptoServiceProvider
'pass keys
objEncryptor = objDES.CreateEncryptor(arrDESKey, arrDESIV)
'create to file to save password
objFileStream = New FileStream(MapPath("secret.txt"), FileMode.Create, FileAccess.Write)
'pass in file and keys
objCryptoStream = New CryptoStream(objFileStream, objEncryptor, CryptoStreamMode.Write)
'pass in text
objCryptoStream.Write(arrInput, 0, arrInput.Length)
objCryptoStream.Close()
lblDone.Text = "Done!"
End Sub
It works fine. But, how to i save this encrypted password into a database field instead of a writing it to a file? Also, could some please tell me how to paste code into this forum? I tried <code></code> tags but it did not work.
Many thanks,
Kevin
View 9 Replies
View Related
Jan 27, 2006
hi to all !!!!
i want to store the image file from user click in SQL Server , so how can i ??
How can i Store image (.jpg , .gif) in a database .
pls send me Code or any thing which helps me ...
View 1 Replies
View Related
Jun 7, 2006
Images, PDFs, word documents, etc..., will it affect the performance of my sql if I stored them in it as blob objects? Or it's better to use the filesystem instead and just store file paths in my sql?
thanks in advance
View 1 Replies
View Related
Sep 24, 2001
Can you store images in a database or in a table, or do you have to only store the image path/name in the database while the image is in another folder? IF anyone knows, please share with me. Thanks.
View 2 Replies
View Related
Dec 30, 2007
Hi i am creating a web page which will return the results of products, the store name and the distance of the store from the postcode which the user has put into a text box. My first question is how would my database structure look, below is what it looks like at the moment;
Company; companyID, companyName, companyAddressLine1, companyAddressLine2, companyPostcode.
and
Products; productID, productName, companyID, price.
In order to achieve the proximity search how would i alter the "Company" table, as in what columns will need to be added or removed, thank you
View 1 Replies
View Related
Jan 24, 2008
how store video files in sql database.Also i want to know cording part
View 3 Replies
View Related
Aug 22, 2007
We are creating an enterprise application for fuel, and I am fighting with my DBA about the proper way to store volume and currency in the database. We have 2 main arguments. The first argument is whether we should store costs in the database in $ and convert in the presentation layer, or to store the amount and currency in the database. We sell product from the US in dollar but depending on the customer we may invoice in Euro. Our second argument is the same, execept with volume and UOM. We often purchase product by BBL but sell/transfer by gallon, or Ton.
please tell us the best practice for our dilemma.
View 2 Replies
View Related