Showing posts with label error. Show all posts
Showing posts with label error. Show all posts

Wednesday, March 21, 2012

Is it possible to create CLR function call legacy C++ models?

I tried to convert an legacy C++ program to managed C++ and build a CLR
function. However, too much compiler error. Is it possible to build a CLR
function and call/link.. the legacy C++ code?examnotes <nick@.discussions.microsoft.com> wrote in
news:DA2E1EC7-EFDB-4111-B3A9-0314A8FAA394@.microsoft.com:

> I tried to convert an legacy C++ program to managed C++ and build a
> CLR function. However, too much compiler error. Is it possible to
> build a CLR function and call/link.. the legacy C++ code?
>
As (I believe) I replied earlier to you, you need to either access the C++
object through P/Invoke or COM Interop. In your case it sounds like
P/Invoke is the most likely way of getting to the code, i.e. your C++
object is not a COM component.
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb at develop dot com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********|||Thanks. Sorry for repost.
One thing I want to know is,
It sounds CLR function required /clr:safe, can safe code still do platform
invoke?
"Niels Berglund" wrote:

> examnotes <nick@.discussions.microsoft.com> wrote in
> news:DA2E1EC7-EFDB-4111-B3A9-0314A8FAA394@.microsoft.com:
>
> As (I believe) I replied earlier to you, you need to either access the C++
> object through P/Invoke or COM Interop. In your case it sounds like
> P/Invoke is the most likely way of getting to the code, i.e. your C++
> object is not a COM component.
> Niels
>
> --
> ****************************************
**********
> * Niels Berglund
> * http://staff.develop.com/nielsb
> * nielsb at develop dot com
> * "A First Look at SQL Server 2005 for Developers"
> * http://www.awprofessional.com/title/0321180593
> ****************************************
**********
>|||examnotes <nick@.discussions.microsoft.com> wrote in
news:7205E76E-7B6D-4572-B5EF-B01A7E312456@.microsoft.com:

> It sounds CLR function required /clr:safe, can safe code still do
> platform invoke?
>
In order to do P/Invoke you need to create your assembly in SQL as unsafe.
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb at develop dot com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********|||"Niels Berglund" <nielsb@.nospam.develop.com> wrote in message
news:Xns97AADD8FEE8DEnielsbdevelopcom@.20
7.46.248.16...
> examnotes <nick@.discussions.microsoft.com> wrote in
> news:7205E76E-7B6D-4572-B5EF-B01A7E312456@.microsoft.com:
>
> In order to do P/Invoke you need to create your assembly in SQL as unsafe.
>
Running unsafe code in the database is, well, unsafe. Your legacy C++ code
can crash SQL Server. So you should check with whoever owns the production
SQL Server you will target and make sure they are OK with you running this
code inside the database.
David|||Organization: DevelopMentor
Message-ID: <Xns97AB12F509BB6nielsbdevelopcom@.207.46.248.16>
User-Agent: Xnews/2006.03.14
Newsgroups: microsoft.public.sqlserver.programming
Date: Wed, 19 Apr 2006 17:51:47 -0700
NNTP-Posting-Host: 69.177.80.118.adsl.snet.net 69.177.80.118
Path: TK2MSFTNGP01.phx.gbl!TK2MSFTNGP04.phx.gbl
Lines: 1
Xref: TK2MSFTNGP01.phx.gbl microsoft.public.sqlserver.programming:597705
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
news:ufkHThAZGHA.4836@.TK2MSFTNGP05.phx.gbl:

> Running unsafe code in the database is, well, unsafe. Your legacy C++
> code can crash SQL Server. So you should check with whoever owns the
> production SQL Server you will target and make sure they are OK with
> you running this code inside the database.
>
Well, to put things into perspective; running unsafe CLR code inside the
database is inherently safer than running extended procs. But yes, you are
right in that the code should be checked so it won't cause damage.
Niels
****************************************
**********
* Niels Berglund
* http://staff.develop.com/nielsb
* nielsb at develop dot com
* "A First Look at SQL Server 2005 for Developers"
* http://www.awprofessional.com/title/0321180593
****************************************
**********|||"Niels Berglund" <nielsb@.nospam.develop.com> wrote in message
news:Xns97AB12F509BB6nielsbdevelopcom@.20
7.46.248.16...
> "David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
> news:ufkHThAZGHA.4836@.TK2MSFTNGP05.phx.gbl:
>
> Well, to put things into perspective; running unsafe CLR code inside the
> database is inherently safer than running extended procs. But yes, you are
> right in that the code should be checked so it won't cause damage.
>
Unsafe managed code is one thing. P/Invoke to legacy C++ code is another.
David|||well, clr function call legacy dll has too much trouble,
- need to set security to let the user has permission
- or create public key and use it to sign the assembly
- parameter passing...
make the solution less favorite.
i will go to bcp to text file, processing and bulk insert back
"David Browne" wrote:

> "Niels Berglund" <nielsb@.nospam.develop.com> wrote in message
> news:Xns97AB12F509BB6nielsbdevelopcom@.20
7.46.248.16...
> Unsafe managed code is one thing. P/Invoke to legacy C++ code is another.
> David
>
>sql

Monday, March 12, 2012

Is it possible run C# .net Standard against SQL Server 2000?

Hi all!

I keep getting an error when I try and create a new data connection. This is the error I'm getting:

Unable to connect to database.
It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access with this version of Visual Studio.

I can connect to Access without any problems. Is there anyway around this?
I'm using C# .net Standard with SQL Server 2000.

Thanks for any help.>>It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access with this version of Visual Studio.

What version?? "C#.net standard" ??

What version of the .NET framework are you using? What IDE are you using?|||Thanks ehorn for reply

I'd like to runVisual C#.net 2003 Standard IDE against SQL Server 2000

I'm using Framework 1.1|||Given that you say this is the error:

Unable to connect to database.
It is only possible to connect to SQL Server Desktop Engine databases and Microsoft Access with this version of Visual Studio.

I imagine that the problem is exactly what it says. That is, the version you are using will NOT allow you to access SQL Server. However, if you install the MSDE on your machine (which is binary compatible with SQL Server) you will be able to access that.|||Thanks Douglas for reply!

It was exactly what I did but now trying to install MSDE I'm getting the error:
'The instance name specified is invalid.'

Will I have to remove SQL Server first then try again?|||I expect so, or alternately, specify an instance name while installing MSDE.

Friday, March 9, 2012

Is it not possible to use UPDATE within a function?

Is it not possible to use UPDATE within a function? I get the following err
or message for the following function:
Evan
- - - - - - - - - - - - - -
Server: Msg 443, Level 16, State 2, Procedure fn_GetNextDataVersion, Line 10
Invalid use of 'UPDATE' within a function.
CREATE FUNCTION dbo.fn_GetNextDataVersion(@.tb_pk int)
RETURNS bigint
AS
BEGIN
DECLARE @.nextDataVersion bigint
SET @.nextDataVersion = 1 + (SELECT DataVersion FROM tb_TableList WHERE tb_pk
= @.tb_pk)
UPDATE tb_TableList SET DataVersion = @.nextDataVersion WHERE tb_pk = @.tb_pk
RETURN @.nextDataVersion
ENDDDL statements inside user-defined functions are only allowed on table
variables local to the function.
http://msdn.microsoft.com/library/d...>
_08_460j.asp
Objects cannot be created, altered or dropped if they exist outside the
scope of the user-defined function.
ML
http://milambda.blogspot.com/|||Table variables IF a table is created in that function?
"ML" <ML@.discussions.microsoft.com> wrote in message
news:B2FA2009-C30A-4DF4-B8CE-DC110EA8F77A@.microsoft.com...
> DDL statements inside user-defined functions are only allowed on table
> variables local to the function.
> http://msdn.microsoft.com/library/d...
es_08_460j.asp
> Objects cannot be created, altered or dropped if they exist outside the
> scope of the user-defined function.
>
> ML
> --
> http://milambda.blogspot.com/|||Yes. Locally. Variables are always local in SQL.
("This is a local shop. For local people." -- from 'A League of Gentlemen'
(BBC))
What is your goal exactly - there might be another way. If you share the
goal. :)
ML
http://milambda.blogspot.com/|||Create a function which gets a counter from a table and return the counter
WHILE updating the counter table to PLUS ONE
Evan
"ML" <ML@.discussions.microsoft.com> wrote in message
news:854D1DA1-3C1C-45B7-8A9B-E787B3856E55@.microsoft.com...
> Yes. Locally. Variables are always local in SQL.
>
> ("This is a local shop. For local people." -- from 'A League of Gentlemen'
> (BBC))
>
> What is your goal exactly - there might be another way. If you share the
> goal. :)
>
> ML
> --
> http://milambda.blogspot.com/|||for now i am working with a stored proc but a function is more elegant|||If you want to do it in a single step, then the procedure is the way to go.
ML
http://milambda.blogspot.com/

Wednesday, March 7, 2012

is it a good practice to do integrity check before perform backup?

On maintenance plan, there is a check box on integrity tab page, is it a good
way to do that first? if there is error found, will the backup stop? thanks
Hi
It depends on what error it will find. Actually, you can checkbox but make
sure that you uncheck Attempt to repair... option.
"tulip" <tulip@.discussions.microsoft.com> wrote in message
news:06E26A1F-4F08-4D81-9502-07E9DB0F5041@.microsoft.com...
> On maintenance plan, there is a check box on integrity tab page, is it a
> good
> way to do that first? if there is error found, will the backup stop?
> thanks
|||My approach is that if you have plenty of maintenance window for doing the
integraity checks (i.e. DBCC checks), do them by all means. And if you are
running into integrity issues, you may want to perform the DBCC checks more
regularly. It becomes a more difficult question when you are dealing with a
large amount of data and when you are struggling to contain your maintenance
jobs inside a limited maintenance window. In that case, you may have to forgo
the DBCC checks or do them very selectively.
Linchi
"tulip" wrote:

> On maintenance plan, there is a check box on integrity tab page, is it a good
> way to do that first? if there is error found, will the backup stop? thanks

is it a good practice to do integrity check before perform backup?

On maintenance plan, there is a check box on integrity tab page, is it a good
way to do that first? if there is error found, will the backup stop? thanksHi
It depends on what error it will find. Actually, you can checkbox but make
sure that you uncheck Attempt to repair... option.
"tulip" <tulip@.discussions.microsoft.com> wrote in message
news:06E26A1F-4F08-4D81-9502-07E9DB0F5041@.microsoft.com...
> On maintenance plan, there is a check box on integrity tab page, is it a
> good
> way to do that first? if there is error found, will the backup stop?
> thanks|||My approach is that if you have plenty of maintenance window for doing the
integraity checks (i.e. DBCC checks), do them by all means. And if you are
running into integrity issues, you may want to perform the DBCC checks more
regularly. It becomes a more difficult question when you are dealing with a
large amount of data and when you are struggling to contain your maintenance
jobs inside a limited maintenance window. In that case, you may have to forgo
the DBCC checks or do them very selectively.
Linchi
"tulip" wrote:
> On maintenance plan, there is a check box on integrity tab page, is it a good
> way to do that first? if there is error found, will the backup stop? thanks

Monday, February 20, 2012

Is AUTOGROW info recorded?

Is the before & after size, autogrow start & complete time , or any other
info related to auto-growing of datafiles recorded in an error log / event /
sql log / anywhere?
tia
chris
It's not audited, AFAIK.
-oj
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:1AE8AB19-BE65-489A-91BA-F35FC4049D90@.microsoft.com...
> Is the before & after size, autogrow start & complete time , or any other
> info related to auto-growing of datafiles recorded in an error log / event
> /
> sql log / anywhere?
> tia
> chris
|||Chris wrote:
> Is the before & after size, autogrow start & complete time , or any
> other info related to auto-growing of datafiles recorded in an error
> log / event / sql log / anywhere?
> tia
> chris
You can detect an auto grow op in Profiler under Database - Data Auto
Grow /Shrink and Log Auto Grow / Shrink.
David Gugick
Imceda Software
www.imceda.com

Is AUTOGROW info recorded?

Is the before & after size, autogrow start & complete time , or any other
info related to auto-growing of datafiles recorded in an error log / event /
sql log / anywhere?
tia
chrisIt's not audited, AFAIK.
-oj
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:1AE8AB19-BE65-489A-91BA-F35FC4049D90@.microsoft.com...
> Is the before & after size, autogrow start & complete time , or any other
> info related to auto-growing of datafiles recorded in an error log / event
> /
> sql log / anywhere?
> tia
> chris|||Chris wrote:
> Is the before & after size, autogrow start & complete time , or any
> other info related to auto-growing of datafiles recorded in an error
> log / event / sql log / anywhere?
> tia
> chris
You can detect an auto grow op in Profiler under Database - Data Auto
Grow /Shrink and Log Auto Grow / Shrink.
David Gugick
Imceda Software
www.imceda.com

Is AUTOGROW info recorded?

Is the before & after size, autogrow start & complete time , or any other
info related to auto-growing of datafiles recorded in an error log / event /
sql log / anywhere?
tia
chrisIt's not audited, AFAIK.
--
-oj
"Chris" <Chris@.discussions.microsoft.com> wrote in message
news:1AE8AB19-BE65-489A-91BA-F35FC4049D90@.microsoft.com...
> Is the before & after size, autogrow start & complete time , or any other
> info related to auto-growing of datafiles recorded in an error log / event
> /
> sql log / anywhere?
> tia
> chris|||Chris wrote:
> Is the before & after size, autogrow start & complete time , or any
> other info related to auto-growing of datafiles recorded in an error
> log / event / sql log / anywhere?
> tia
> chris
You can detect an auto grow op in Profiler under Database - Data Auto
Grow /Shrink and Log Auto Grow / Shrink.
--
David Gugick
Imceda Software
www.imceda.com