Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> running an sql script file with llblgen
 

Pages: 1
LLBLGen Pro Runtime Framework
running an sql script file with llblgen
Page:1/1 

  Print all messages in this thread  
Poster Message
BexMed
User



Location:

Joined on:
18-Jul-2007 17:01:40
Posted:
63 posts
# Posted on: 18-Jul-2007 17:06:55.  
Hello!

Is it possible to pass an sql script file (ie test.sql) into llbgen and it to run it? This script file may include "GO"s, but it doesn't have to.

This file may be a scripted version of the database which the website wil run on the first use to create the database.

Thanks

Becky
  Top
jmeckley
User



Location:
Harrisburg, PA, USA
Joined on:
05-Jul-2006 16:03:19
Posted:
403 posts
# Posted on: 18-Jul-2007 20:09:02.  
not without some heavy modifications to the code.
if you need scripts to run once on install I would make this part of the install process, not the application. the most basic approach would be a bat file to connect to the db, and run a script.


Jason Meckley
Programmer
 
Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1118 posts
# Posted on: 19-Jul-2007 03:22:04.  
Can you not just derrive a custom IExpression where it just outputs the string you pass in?



SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14626 posts
# Posted on: 19-Jul-2007 10:13:38.  
Check this thread:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=3380


  Top
BexMed
User



Location:

Joined on:
18-Jul-2007 17:01:40
Posted:
63 posts
# Posted on: 19-Jul-2007 10:30:30.  
Thanks Walaa

That's exactly what I want to do..!

Quote:

Derive a class from DataAccessAdapter, then add a method to that class which calls CreateNewPhysicalConnection, to get a connection object. Using that connection object, you can execute FbCommand objects


Just a quick question though.. will this way of doing it cope with the "GO"s in the scripts or will it fall over like normal .NET database commands do?

I am still only just getting to grips with LLBLGEN so would it be possible that you could give me an example of how I would excecute the command with my connection object?

Thanks in advance

Bex

  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14626 posts
# Posted on: 19-Jul-2007 10:58:03.  
The before mentioned approach suggests you use a normal ADO.NET to execute the script, but it shows you how to get a connection object from the DataAccessAdapter to be used in the ADO.NET code.

  Top
BexMed
User



Location:

Joined on:
18-Jul-2007 17:01:40
Posted:
63 posts
# Posted on: 19-Jul-2007 12:05:47.  
Ah ok, so I just call the connection object and then use my own code to exceute the cmd.

Would I be able to use this
Code:
adapter.ExecuteActionQuery(SQLCOMMAND)

to do anything like that?

I cannot find anything in the documentation about this command, but it seems as if I should just pass this a query and it should do it? like when you pass a stored procedure to CallActionStoredProcedure?

I keep getting, "connection not present" at the moment tho when it definitly is present!

Thanks

Bex
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14626 posts
# Posted on: 19-Jul-2007 15:36:25.  
Quote:
Would I be able to use this
Code:
adapter.ExecuteActionQuery(SQLCOMMAND)

to do anything like that?

I cannot find anything in the documentation about this command, but it seems as if I should just pass this a query and it should do it?

Check this out:
http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7165


  Top
JimHugh
User



Location:
Davis, CA
Joined on:
16-Nov-2005 14:32:25
Posted:
191 posts
# Posted on: 19-Jul-2007 17:20:14.  
Haven't tried this yet, but this blog post looks promising! (along with the advice above about getting a connection object from LLBLGen.)

http://weblogs.asp.net/jgalloway/archive/2006/11/07/Handling-_2200_GO_2200_-Separators-in-SQL-Scripts-_2D00_-the-easy-way.aspx

be aware that you might run into a chicken and egg problem if you are trying to create the database that is not built yet using scripts , but specified in the connection string.
Jim Hughes  Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1118 posts
# Posted on: 19-Jul-2007 17:25:41.  
Back on the main subject of this thread, it would be nice if the templates did provide a way to execute 'manual sql'.

However, having said that, if you get something working - put it in a template and share with everyone. Maybe then someday, we can talk Otis into including it...


SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
jmeckley
User



Location:
Harrisburg, PA, USA
Joined on:
05-Jul-2006 16:03:19
Posted:
403 posts
# Posted on: 19-Jul-2007 17:33:11.  
my $.02...

doesn't providing direct sql access defeat the purpose of LLBL? the idea is to provide strongly typed objects to access the db. providing direct sql script access bypasses everything. There is no way to validate the script, so you could run into exceptions at runtime, more so than using LLBL objects.
Jason Meckley
Programmer
 
Top
WayneBrantley
User



Location:
USA
Joined on:
10-Mar-2006 16:20:08
Posted:
1118 posts
# Posted on: 19-Jul-2007 17:39:09.  
Yes, it does....but there are situations like the above. Or upgrade database version scripts, etc. Where you actually do need this feature.

SelfServicing, .Net 4.5, Web Applications, SqlServer 2014  Top
tzarger
User



Location:
Phoenix, AZ
Joined on:
14-Jun-2007 08:14:30
Posted:
87 posts
# Posted on: 19-Jul-2007 21:31:53.  
BexMed wrote:
Hello!

Is it possible to pass an sql script file (ie test.sql) into llbgen and it to run it? This script file may include "GO"s, but it doesn't have to.

This file may be a scripted version of the database which the website wil run on the first use to create the database.

Thanks

Becky


Personally, I have an app I wrote to migrate data from one database to a different database with a completely different schema... I created 3 Stored Procs:

  • one to delete the new database
  • one to create the tables, etc.
  • And lastly one to add the relationships and indexes


In LLBLGen, I have those three ActionProcedures that get built in when I generate my db... and then in my code I simply call them... Now if you are talking about random things, this would not work... but in the case of setting up a db first for the site to use, this would work in your situation I believe.

I hope this might be some help...
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.