|
Ok, I've found one way to do this but it's hardly elegant and it doesn't allow you to take advantage of delayed execution:
DataContext.GetCommand returns System.Data.Common.DbCommand which allows you to access the Parameters collection where you can set the size. If you're using SQL Server you need to set Precision you'll have to cast the parameter to a SqlParameter.
After you've updated the parameter you can call ExecuteReader (don't forget to make sure the connection is open). Then use the DataContext.Translate<tresult(dbdatareader) method="" to="" convert="" the="" datareader="" ienumerable<t="">.
The problem is this doesn't allow for delayed execution because you can't update the actual command used by the query variable.
|
|
|
|
|
Just as an update, I've found a way to inject my workaround (read: hack) into the process in a way that is transparent to the consumer of my class. I'm going to create a class which wraps System.Data.Linq.Table<t> and create a custom implementation of the GetEnumerator() and GetEnumerator<t>() methods which will parse the expression tree (haven't proved this part of the concept yet) and determine the parameter mappings, then I'll be able to reflect over T (I'll have to cache the result of this for performance) to determine the correct value for DbParameter.Size.
When I've completed the ability to parse the expression tree I'll write an article on everything I've learned. Wish me luck!
Mark
|
|
|
|
|
Please how can I insert a table from excel file into an sqlserver table programmatically using C#.That is create a table in sqlserver with a file in excel that already have the table defined.Using c#.
|
|
|
|
|
By searching Google[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I want to query a table for the previous date.
Not sure how to construct the WHERE statement.
Thanks,
|
|
|
|
|
The answer was;
WHERE [TimeStamp]>= Convert(varchar(10), DateADD(DAY, -1, GETDATE()), 101) AND [TimeStamp] < Convert(varchar(10), GETDATE(), 101)
This gave the info for the previous day only.
Brian
|
|
|
|
|
Hi all,
I have the following script to do a back up of SQL2005 database:
BACKUP DATABASE [Repo] TO DISK = N'C:\Program Files\repo.dat' WITH NOFORMAT, NOINIT, NAME = N'repor-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO
When i try to look for Repo.dat file under C:\programfiles i cant get it.
Please advice
Thanks
|
|
|
|
|
SQL Server would save it to the filesystem on the machine in which SQL Server is running, not on the client box from where you issue the backup command.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
hi
My aim is to retrieve a picture from a access database ................
This is the code which i am using
byte[] bt = (byte[])(bindreader[0]);
MemoryStream mst = new MemoryStream();
mst.Write(bt, 0, bt.Length);
pbox.BackgroundImage = Image.FromStream(mst);
its working fine when the image is stored through code it will be in long binary format
when i am inserting image thru access its in the bmp so its creating a problem if any one knows how to tackle this situation please help me .
regards
sindhu tiwari
always innovative
|
|
|
|
|
I am willing to take on datawarehousing course. what things to keep in mind for choosing a course from an institute or for choosing which institute to got for it.
I have worked upto reporting services and integration services in sql server 2005 and would like to go ahead with database side.
I am in mumbai (India) and if someone can suggest me out, it will be a great help.
Thanks.
Jwalant Natvarlal Soneji BE IT, India
|
|
|
|
|
I went on a course for Reporting Services last month. The trainer just went through the Reporting Services step-by-step book. I could have done that myself.
If you are paying for this yourself, I recommend that you buy the Step-by-Step book and then take a week off to study it.
|
|
|
|
|
hey everyone i am getting this error on sql server 2005:
" An error has occured while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server )"
could anybody help me out here?
Luis E Tineo S
|
|
|
|
|
set the remote connection...
|
|
|
|
|
You must enable remote connections for each instance of SQL Server 2005 that you want to connect to from a remote computer. To do this, follow these steps:
1. Click Start, point to Programs, point to Microsoft SQL Server 2005, point to Configuration Tools, and then click SQL Server Surface Area Configuration.
2. On the SQL Server 2005 Surface Area Configuration page, click Surface Area Configuration for Services and Connections.
3. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Remote Connections, click Local and remote connections, click the appropriate protocol to enable for your environment, and then click Apply.
Note Click OK when you receive the following message:
Changes to Connection Settings will not take effect until you restart the Database Engine service.
4. On the Surface Area Configuration for Services and Connections page, expand Database Engine, click Service, click Stop, wait until the MSSQLSERVER service stops, and then click Start to restart the MSSQLSERVER service.
|
|
|
|
|
hi there,
i m using sql server 2005, and i wanna know how can i change primary key data
for example :
i have 3 tables
1. have 3 columns(EmpID, Salary, RegID)
where EmpID is Primary key and RegID is unique Key
2. have 2 columns(EmpID, Work)
where EmpID is Foreign key
3. have 2 columns(EmpID, Status)
where EmpID is Foreign key
now i wanna change EmpID in all 3 tables,
so i try do it something like this, as i know it will give error and wont work
Update Table1 set EmpID = XX where RegID = XX
can someone tell how can i do this... mean if i change EmpID in table 1 then it automatically change EmpID in others tables
is it possible? or any other way?
thanks
Becoming Programmer...
|
|
|
|
|
Well, its a bit of a strange thing to do as primary keys aren't supposed to change and the foreign keys are there to maintain integrity between tables.
I think you'd need to drop your foreign key constraints, perform the update on the main table, then perform updates on table 2 and 3 so everything points to where it should and reintroduce your foreign keys.
Regards,
Rob Philpott.
|
|
|
|
|
If you specify ON UPDATE CASCADE option when creating the foreign keys, updates to Primary key will reflect in Foreign keys.
Check MSDN to know how to specify this option using T-SQL code or management studio.
|
|
|
|
|
thanks dude
Becoming Programmer...
|
|
|
|
|
Hi,
I have got a problem on a XP Pro development machine using SQL Server 2005, VS 2005. During my development and testing of a Web 2.0 app, I have sporadic times in executing the same query. A query will run within a second for a while and then will start taking 30 seconds to complete. I have tried restarting sql server with no effect. The only thing that fixes it is the restart the machine. It doesn't seem to be linked to a particular query. Has anyone else had this problem?
Thanks, Jared
|
|
|
|
|
Once the query starts taking a long time to return in the asp.net app, I have copy the query into management studio and ran it to check it has anything to do with asp.net and it still takes a long time to run.
|
|
|
|
|
I believe that this is probably due to not having enough memory on my machine. I have 1GB which is nearly all used with those hungry microsoft products. I will need to do some further testing to confirm this.
|
|
|
|
|
I am trying to run this query;
declare @StartDate DateTime
declare @EndDate DateTime
set @StartDate = cast('2007/10/22' as DateTime)
set @EndDate = cast('2007/11/05' as DateTime)
SELECT RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, COUNT(RT_MCP_Alarm_Text) AS Error_Count, CONVERT(char(10), RT_MCP_Date_Time, 111) as ErrorDate, RT_MCP_Bit_State as BOOLEAN
FROM RT_MCP_Historic_Alarms
where RT_MCP_Date_Time >@StartDate and RT_MCP_Date_Time <dateadd(day, 1,@enddate)="" and="" rt_mcp_alarm_text="" <u="">RT_MCP_Bit_State <> FALSE
GROUP BY RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text, CONVERT(char(10), RT_MCP_Date_Time, 111)
ORDER BY RT_MCP_Date_Time, Error_Count DESC, RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text
I recieve this error when I try to run it. The BOLDED column is a BIT type, for a True/False choice. I do not need to know when the items go false, only when the meet the TRUE bit.
Thanks,
|
|
|
|
|
Use 0 and 1 to test a BIT value
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Figured this out after I wrote it.
The other problem I had was;
ORDER BY RT_MCP_Date_Time, Error_Count DESC, RT_MCP_Name, RT_MCP_State, RT_MCP_Alarm_Text
I declared the RT_MCP_Date_Time as ErrorDate in the select statement and didn't put it in the ORDER BY statement correctly.
Thanks for your help.
|
|
|
|
|
Hi, I'm new with the SQL language. I would like to ask for tips
or advice on what part of the SQL server to start?
I'll really appreciate the help.
Thanks.
|
|
|
|