|
XPO is an object/relational mapper. The purpose of these is to abstract away the details of loading data into your object and persisting it, so you can concentrate on OO business logic rather than database plumbing.
But if you're fairly unfamiliar with SQL I would learn that first. Then later on you will gain an appreciation of XPO (or similar object/relational mappers).
Kevin
|
|
|
|
|
I ve written a stored procedure to fetch data from a table. Here i m getting an error "Syntax error converting datetime from character string.". Please guide me.
//////////////////////////////////////////////////////////////////////////
CREATE PROCEDURE ic_get_processeddata
(
@frmDate DateTime,
@toDate DateTime,
@empType varchar(20),
@ein varchar(15)
)
as
declare @sqlStr as varchar(255)
set @sqlStr =''
set @sqlStr='select EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus from ic_process where frmDate='+@frmDate+' and toDate='+@toDate
if(@empType !='')
begin
set @sqlStr = @sqlStr + ' and empType=' + @empType
end
if(@ein !='')
begin
set @sqlStr = @sqlStr + ' and EIN='+@ein
end
set @sqlStr = @sqlStr + (' order by empName,empType')
print(@sqlStr)
exec @sqlStr
GO
thanx in advance
|
|
|
|
|
Use CAST or CONVERT to convert @frmDate and @toDate to string , before you try to concatenate them.
|
|
|
|
|
Wouldn't this be a better solution:
CREATE PROCEDURE ic_get_processeddata
(
@frmDate DateTime,
@toDate DateTime,
@empType varchar(20),
@ein varchar(15)
)
AS
SELECT EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus
FROM ic_process
WHERE frmDate = @frmDate AND toDate = @toDate
AND (empType = @empType OR @empType = '')
AND (EIN = @ein OR @ein='')
ORDER by empName,empType
This way the @toDate remains a datetime type.
|
|
|
|
|
Hi szukuro
Thanx for your suggestion. But your tric was not working for my solution. Some how i modified my stored procedure. Is this the correct way?? can we optimized it??
CREATE PROCEDURE ic_get_processeddata
(
@frmDate DateTime,
@toDate DateTime,
@empType varchar(20),
@ein varchar(15)
)
as
if(@empType !='') and (@ein !='')
begin
select EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus from ic_process where frmDate=@frmDate and toDate=@toDate and empType=@empType and ein=@ein order by empType,empName
end
else if (@empType !='') and (@ein ='')
begin
select EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus from ic_process where frmDate=@frmDate and toDate=@toDate and empType=@empType order by empName,empType
end
else if(@ein !='') and (@empType ='')
begin
select EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus from ic_process where frmDate=@frmDate and toDate=@toDate and ein=@ein order by empName,empType
end
else
begin
select EIN,empName,empType,I2C,callAnswered,I2CPer,USLeaves,CBF,SOS,SOI,FCR,Bonus from ic_process where frmDate=@frmDate and toDate=@toDate order by empName,empType
end
GO
|
|
|
|
|
Why didn't it work? What was the problem?
|
|
|
|
|
iam working with vb.net using web applications
my webform1.aspx page consists of imagebutton(id=ibmap),button(id=download)
iam displaying a map in imagebutton by using shapefiles data
now i want to give an option to user to download that map
when user clicks on the button map must be downloaded with .gif extension
i wrote the code ,but it is not displaying the map
my code is
Private Sub butdownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles butdownload.Click
dim filepath As String = Server.MapPath("test.gif")
Dim filename As String = Path.GetFileName(filepath)
Response.Clear()
Response.ContentType = "application/octet-stream"
Response.AddHeader("Content-Disposition", "attachment; filename=""" & filename & """")
Response.Flush()
filename = ibMap.ImageUrl
Response.WriteFile(filename)
Response.End()
end sub
plz currect my code
|
|
|
|
|
You need to change the content type:
Response.ContentType = "Image/GIF"
remove this line if you want the image to open in the same page:
Response.AddHeader("Content-Disposition", "attachment; filename=""" & filename & """")
Sample code that worked on my PC:
Dim filename As String
Response.Clear()
Response.ContentType = "Image/GIF"
filename = "C:\imagename.GIF"
Response.WriteFile(filename)
Response.End()
|
|
|
|
|
i have a Query, below, i was to Display results based on the first results
select* from property where substring(func_key,1,5)='GEOSS'
(select * from property where
substring(func_key,6,8) <=2)
1)First Query will Display all records where in the Functional key column there is 'GEOOS' accordingly and it working, and i want to search again from this results.
2)I want to Search all records where Fun_key is <=2, based on the First one.
when i run this Query here is the Error i get.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
(40569 row(s) affected)
Server: Msg 245, Level 16, State 1, Line 2
Syntax error converting the varchar value 'J00' to a column of data type int.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Help
Vuyiswa
|
|
|
|
|
Can U try this?
select* from property where substring(func_key,1,5)='GEOSS'
AND substring(func_key,6,8) <=2)
or
Select * from
(select* from property where substring(func_key,1,5)='GEOSS')A
where substring(func_key,6,8) <=2
Regards,
Arun Kumar.A
|
|
|
|
|
/***Find All the GEOSS records that start from 1 ends with 2****/
select* from property where substring(func_key,1,5)='GEOSS'
AND substring(func_key,6,8) <=2
/*from the Above results i want to Select Distinct the Functional Key*/
select distinct fun_key from "(above results)"
Vuyiswa
|
|
|
|
|
Try this:
select distinct(func_key) from property where substring(func_key,1,5)='GEOSS'
AND substring(func_key,6,8) <=2
Regards,
Arun Kumar.A
|
|
|
|
|
Thank man it work.
Vuyiswa
|
|
|
|
|
Hello
I have a task coming up shortly which involves loading several BILLION rows of data from a text file into SQL 2000.
Wondering what the fastest way to do this is eg SQL BULK INSERT or code it up in C# executable etc.
Does anyone know any tips or tricks?
|
|
|
|
|
From one text file? Is it at least CSV or fixed-width?
The SQL Server bulk copy utility is bcp , but I wouldn't use it for such an extensive import, I'd use a program (written in C#, but that's just me).
I would have the program commit and checkpoint its position in the file once in a while (10000 rows?) so it can restart near where it left off after a failure. With bcp you'd probably have to start all over.
In my database library routines I also have the ability to make a log entry every so many inserts or seconds so I can watch the log and be sure it's actually still progressing, and get a feel for how long it's taking. With bcp you're flying blind.
I do occasionally use bcp for small imports, and it usually involves importing to a sort of "raw" table from whence I can then copy the data to the proper places, especially if data from each row has to be put into several tables.
|
|
|
|
|
Thanks for the info. Data is in several files.
I'll write some C# stuff to analyse it and make sure there are no errors before load. Tried a test on that yesterday with hundred million rows and only took a couple of minutes. Slow point is SQL import.
Commit at intervals is a good idea.
Testing 1 million rows import at the moment (C# and Stored Procedure) and getting about 7 minutes. Thats only five days processing for a billion records...
Might try SqlBulkCopy class next and see whether thats any faster.
Thanks
-- modified at 1:40 Friday 4th May, 2007
SqlBulkCopy - 14 seconds!
|
|
|
|
|
Wel wel,
I always new that stored procedures are faster then runtime build queries, but i bumped into something weird and now i have my doubts.
- Retrieving data with a normal query returns a table length 4000 bytes returned from server.
- Retrieving exactly the same data using a stored procedure returns a table length of 6800 bytes returned from server.
So if bandwidth is important for example on 128000 bits/sec connection, then i suppose i go for the Queries..
is there an expert who can explain this item?
Thx
Kurt
|
|
|
|
|
What is the difference when large result sets are returned. Is the difference a static 1600 bytes, or is it a percentage of the result set?
|
|
|
|
|
that i don't know, but i suppose it will be static information about the stored procedure. i'll have to test that.
well it takes a difference of nearly 200 ms on a 128000 b/s line
4000 bytes = 250 ms
6800 bytes = 425 ms
so retrieve 5 tables of that kind and you'll end up on 2.1 seconds waiting for data comparing to 1 second.
this can be important yes...
|
|
|
|
|
Iam Moving from vb6 to .Net, i need Advice what is the differences in syntax and where are the difference between the two. give me links to E-books or tutorials
Vuyiswa
|
|
|
|
|
SQL Syntax will remain the same between VB6 and VB.NET as the SQL code is parsed by the database engine.
|
|
|
|
|
thanks man thats good news, so do you have good link for newbies in Vb.net?"
Vuyiswa
|
|
|
|
|
Your best bet is to get a good book on Ado.Net. There is one by Sahil Malik(sp) that I would highly recommend. You should also google for Ado and Net and you will find plenty (try using www.searchdotnet.com instead of straight Google). Ado .Net is quite different from classic Ado and will require a little getting used to.
Aaron
_____________________________________________________________________
Our developers never release
code. Rather, it tends to escape, pillaging the countryside all around.
The Enlightenment Project (paraphrased comment)
Visit Me at GISDevCafe
|
|
|
|
|
Thank you very much Aaron
Vuyiswa
|
|
|
|
|
hi everybody..
anyone here knows how to use the BACKUP DATABASE statement in SQL
please tell me the correct syntax..
thanx in advance..
sandeep..
|
|
|
|
|