Showing posts with label developed. Show all posts
Showing posts with label developed. Show all posts

Wednesday, March 28, 2012

How to connect....HELP

How can I connect to database from a remote computer in the same domain?
I developed many database applications using Access, but now I need a code
snippet to make some of my existing application to run in a remote Sql server
with the same structure (databases, views)...and I can't figure how...
Anybody can help me?
http://www.able-consulting.com/ADO_Conn.htm
"Nando_uy" <Nandouy@.discussions.microsoft.com> wrote in message
news:8E8F6961-D166-45D4-8C8E-3E3CD032B768@.microsoft.com...
> How can I connect to database from a remote computer in the same domain?
> I developed many database applications using Access, but now I need a code
> snippet to make some of my existing application to run in a remote Sql
server
> with the same structure (databases, views)...and I can't figure how...
> Anybody can help me?
sql

How to connect....HELP

How can I connect to database from a remote computer in the same domain?
I developed many database applications using Access, but now I need a code
snippet to make some of my existing application to run in a remote Sql serve
r
with the same structure (databases, views)...and I can't figure how...
Anybody can help me?http://www.able-consulting.com/ADO_Conn.htm
"Nando_uy" <Nandouy@.discussions.microsoft.com> wrote in message
news:8E8F6961-D166-45D4-8C8E-3E3CD032B768@.microsoft.com...
> How can I connect to database from a remote computer in the same domain?
> I developed many database applications using Access, but now I need a code
> snippet to make some of my existing application to run in a remote Sql
server
> with the same structure (databases, views)...and I can't figure how...
> Anybody can help me?

Monday, March 19, 2012

How to configure Smo.Scripter to get desired sprocs

Hi, I've developed a sproc generator using SMO types and all works fine except when I want to generate sprocs prefaced by a drop statement. To do this I create an instance of the Scripter object and set it's options.ScriptDrops property to true ( instance.options.ScriptDrops = true).

When options.ScriptDrops = true the output omits the actual stored procedure from the scriopt. When I comment out scriptDrops = true it works correctly. How do i get it working correctly WITH drop statements?

Example:

private void CreateScripter() {
if( this._SprocSscripter == null ) {
this._SprocSscripter = new Scripter();
this._SprocSscripter.Server = this._tables.Parent.Parent;
this._SprocSscripter.Options.IncludeHeaders = true;
this._SprocSscripter.Options.IncludeIfNotExists = true;
this._SprocSscripter.Options.DdlBodyOnly = false;
this._SprocSscripter.Options.DdlHeaderOnly = false;
this._SprocSscripter.Options.ExtendedProperties = true;
this._SprocSscripter.Options.ScriptDrops = true;
}
}

OUTPUT:

/****** Object: StoredProcedure [dbo].[usp_selectCategories] Script Date: 01/18/2007 16:39:29 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_selectCategories]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_selectCategories]

OUPUT when i comment out last line ( this._SprocSscripter.Options.ScriptDrops = true;)

/****** Object: StoredProcedure [dbo].[usp_selectCategories] Script Date: 01/18/2007 16:37:04 ******/
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_selectCategories]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @.statement = N'CREATE PROCEDURE [dbo].[usp_selectCategories]
@.CategoryID [int]
AS
SELECT [CategoryID],
[CategoryName],
[Description],
[Picture]
FROM [dbo].[Categories]
WHERE [CategoryID] = @.CategoryID
'
END

If I Comment out all lines in the CreateScripter method exect the 1st, 2nd and last ( this._SprocSscripter.Options.ScriptDrops = true;)
The output looks like this:

DROP PROCEDURE [dbo].[usp_selectCategories]

That's it-- no sproc body.. what gives?

Bill Graziano did a great job of documenting how to do this at his SQLTeam.com web site - here's the link to the article:

http://www.sqlteam.com/item.asp?ItemID=23185

|||Excellent. Thank you. Too bad it's a bug, but learning that it is has restored some of my sanity :-)|||

|||

How to configure Smo.Scripter to get desired sprocs

Hi, I've developed a sproc generator using SMO types and all works fine except when I want to generate sprocs prefaced by a drop statement. To do this I create an instance of the Scripter object and set it's options.ScriptDrops property to true ( instance.options.ScriptDrops = true).

When options.ScriptDrops = true the output omits the actual stored procedure from the scriopt. When I comment out scriptDrops = true it works correctly. How do i get it working correctly WITH drop statements?

Example:

private void CreateScripter() {
if( this._SprocSscripter == null ) {
this._SprocSscripter = new Scripter();
this._SprocSscripter.Server = this._tables.Parent.Parent;
this._SprocSscripter.Options.IncludeHeaders = true;
this._SprocSscripter.Options.IncludeIfNotExists = true;
this._SprocSscripter.Options.DdlBodyOnly = false;
this._SprocSscripter.Options.DdlHeaderOnly = false;
this._SprocSscripter.Options.ExtendedProperties = true;
this._SprocSscripter.Options.ScriptDrops = true;
}
}

OUTPUT:

/****** Object: StoredProcedure [dbo].[usp_selectCategories] Script Date: 01/18/2007 16:39:29 ******/
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_selectCategories]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[usp_selectCategories]

OUPUT when i comment out last line ( this._SprocSscripter.Options.ScriptDrops = true;)

/****** Object: StoredProcedure [dbo].[usp_selectCategories] Script Date: 01/18/2007 16:37:04 ******/
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_selectCategories]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @.statement = N'CREATE PROCEDURE [dbo].[usp_selectCategories]
@.CategoryID [int]
AS
SELECT [CategoryID],
[CategoryName],
[Description],
[Picture]
FROM [dbo].[Categories]
WHERE [CategoryID] = @.CategoryID
'
END

If I Comment out all lines in the CreateScripter method exect the 1st, 2nd and last ( this._SprocSscripter.Options.ScriptDrops = true;)
The output looks like this:

DROP PROCEDURE [dbo].[usp_selectCategories]

That's it-- no sproc body.. what gives?

Bill Graziano did a great job of documenting how to do this at his SQLTeam.com web site - here's the link to the article:

http://www.sqlteam.com/item.asp?ItemID=23185

|||Excellent. Thank you. Too bad it's a bug, but learning that it is has restored some of my sanity :-)

Monday, March 12, 2012

How to configure connection string for remote server?

Sorry for the newbie question, but...

I have developed a website on my local development machine. When I create the connections string VS automatically creates a path to my local hard drive inside the string.

Data Source=.\SQLEXPRESS;AttachDbFilename="C:\Documents and Settings\Mike\My Documents\Visual Studio 2005\WebSites\PostAlertz\App_Data\PADatabase.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True

However, when I deploy this website to a remote server, SQLExpress tries to attach to the file using the wrong path. How do I fix this?

Your patience is appreciated...Smile

Hi

Here is a sample connection string,and you can find more onhttp://www.connectionstrings.com/:

Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword;

HOW-TO: Database from VWD to Shared Host tells you how to copy database to share host.

Hope this helps.

|||If you have SQL Express instance installed on the remote server, just set the correct path for the mdf file like:

data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|PADatabase.mdf;User Instance=true