473,412 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Dynamic SQL generation

OuTCasT
374 256MB
Anyone know how to get passed this prblem

Dynamic SQL generation is not supported against multiple base tables
Apr 2 '08 #1
16 2165
gpl
152 100+
Im not entirely sure what you mean - you can write dynamic sql to run against multiple tables.

Are you saying that you have a tool that generates dynamic sql for you and it wont work against multiple tables ?

Graham
Apr 2 '08 #2
debasisdas
8,127 Expert 4TB
Waht exactly you are trying to do ?
Apr 2 '08 #3
OuTCasT
374 256MB
Waht exactly you are trying to do ?
i have a win form
and 2 tables
need to get info from both tables onto the form on page load
so i used a join

created sqlDataAdapter and filled the datatable
now i want to save the data.

Expand|Select|Wrap|Line Numbers
  1. Try
  2.             sqlConnection.Open()
  3.             sqlManager.EndCurrentEdit()
  4.             Dim sqlUpdate As New SqlCommandBuilder(sqlAdapter)
  5.             sqlAdapter.Update(sqlDataTable)
  6.             sqlConnection.Close()
  7.         Catch ex As Exception
  8.             MsgBox(ex.Message, MsgBoxStyle.OkOnly, "SQL Exception Error")
  9.         End Try
that gives me the error
would it work if I wrote an update command for each table rather :??
Apr 2 '08 #4
ck9663
2,878 Expert 2GB
Where's the query?

This could be more of a VB question than a SQL question.

-- CK
Apr 2 '08 #5
OuTCasT
374 256MB
Where's the query?

This could be more of a VB question than a SQL question.

-- CK
i was testing to get the information :

Expand|Select|Wrap|Line Numbers
  1. select s.employeeID , e.firstname , e.Lastname , s.wages from employee e, salary s where e.employeeid = s.employeeid
Apr 3 '08 #6
OuTCasT
374 256MB
Where's the query?

This could be more of a VB question than a SQL question.

-- CK

i filled the dataTable with the sqlAdapter...and created a currency manager to navigate through the records.

Should i create an update command for each table ?
Apr 3 '08 #7
ck9663
2,878 Expert 2GB
If you bind that query in a some sort of adapter or data object, the query is valid but it will be treated as a view. By default, you can not update a view.

-- CK
Apr 3 '08 #8
OuTCasT
374 256MB
If you bind that query in a some sort of adapter or data object, the query is valid but it will be treated as a view. By default, you can not update a view.

-- CK
By default, a view based on one or many tables is updateable.

ive created a view now

Expand|Select|Wrap|Line Numbers
  1. Create view Employees
  2. as
  3. select s.employeeID , e.firstname , e.Lastname , s.wages from employee e, salary s where e.employeeid = s.employeeid
pretty simple now how would i use it in my code ?
Apr 3 '08 #9
ck9663
2,878 Expert 2GB
Well now that you have a view. Try updating it first in query analyzer. Once you did it, try to implement the same technique in your apps.

-- CK
Apr 3 '08 #10
OuTCasT
374 256MB
If you bind that query in a some sort of adapter or data object, the query is valid but it will be treated as a view. By default, you can not update a view.

-- CK
No that wont work.
Gives me an error saying cannot use it because it is a view and not a stored proc.
now ive created a sproc and the information is displayed but when i try add another record and update the datatable it gives me and error saying incorrect syntax near 'employeesStoredProc'
Apr 3 '08 #11
ck9663
2,878 Expert 2GB
I thought you said "
By default, a view based on one or many tables is updateable" ?

-- CK
Apr 3 '08 #12
OuTCasT
374 256MB
I thought you said "
By default, a view based on one or many tables is updateable" ?

-- CK
Thats what is says in my SQL book.
Just went to look how to insert,update.
Apr 3 '08 #13
OuTCasT
374 256MB
I thought you said "
By default, a view based on one or many tables is updateable" ?

-- CK
what i can do is, create 2 select statements that can be update by themselves, but at the end of the day there is going to be like 6 tables with loads of information that has to be update etc....
Apr 3 '08 #14
ck9663
2,878 Expert 2GB
Create a view with all the columns you need. Create a trigger for that view to handle the insert to all tables. Use Transaction processing so that you can rollback if one of the insert fails.

-- CK
Apr 3 '08 #15
OuTCasT
374 256MB
Create a view with all the columns you need. Create a trigger for that view to handle the insert to all tables. Use Transaction processing so that you can rollback if one of the insert fails.

-- CK
i created a trigger for the update of the 2 tables in question

Expand|Select|Wrap|Line Numbers
  1. ALTER trigger [dbo].[InsEmployee] on [dbo].[Employee]
  2. after update
  3. as
  4. if not exists(select s.employeeID , e.firstname , e.Lastname , s.wages from employee e, salary s where e.employeeid = s.employeeid)
  5. begin
  6. raiserror('the employee does not exist',16,1)
  7. rollback transaction
  8. End
Apr 3 '08 #16
ck9663
2,878 Expert 2GB
Create a trigger on the view. Not on the table.

Create the trigger on the view. Inside that trigger, that's where you UPDATE all the tables.

-- CK
Apr 3 '08 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: duncan.lovett | last post by:
I am working on a graphical heading generator for a clients website as their server does not have the GD library or similar plugins for dynamic image generation. I have achieved the result...
11
by: Marco Loskamp | last post by:
Dear list, I'm trying to dynamically generate functions; it seems that what I really want is beyond C itself, but I'd like to be confirmed here. In the minimal example below, I'd like to...
4
by: Venus | last post by:
Hello, Thanks for your reply. I understand that a control can be created dynamically in several ways: 1) using StringBuilder 2) using Controls.Add 3) using ASP PlaceHolder But this is just...
0
by: Venus | last post by:
Hello, After trying some ways to do it I wanted to use something like the code below but for some reason is not working (I have to generate the entire form dynamically (not only the controls)):...
15
by: Nospam | last post by:
Is there a tutorial on dynamic SID generation?
2
by: Ghada Al-Mashaqbeh via DotNetMonster.com | last post by:
Hi all, I am facing a problem in dynamic code generation at run time, the problem occurs when the dynmaic code use global data exist within the original application. Lets say that my...
5
by: pittendrigh | last post by:
There must be millions of dynamically generated html pages out there now, built by on-the-fly php code (and jsp, perl cgi, asp, etc). Programatic page generation is transparently useful. But...
3
by: fedya | last post by:
I am trying to have the last 12 months to always be the option in the dropdown for a combo box. (Basically a combobox, with dynamic options) I am using Access 2000. What is the function and...
7
by: dino d. | last post by:
Hi- I want to create a dynamic image with areas so that when the user clicks different areas, the user jumps to those pages. The problem is, I can't seem to figure out how to do this efficiently....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.