Allow To Select Fields From Two Different Tables?
Apr 13, 2010
I have a data grid view on a form which is currently filled with the following query:
SELECT TopicCode, TopicName, NoOfCourses, Lev FROM tblTopics WHERE TopicCode = @TopicCode1(Where I obviously pass a TopicCode parameter)
However, I have added two custom columns to the data grid view, and the values that i want be in here are in a different table than the query i'm using to fill the data grid view.is it possible to "nest" queries? which will allow me to select fields from two different tables?
Example:SELECT TopicCode, TopicName, NoOfCourses, Duration, Lev FROM tblTopics AND SELECT StartDate, EndDate FROM tblSubscriptions WHERE TopicCode = @TopicCode1
Possible? or not?
View 27 Replies
ADVERTISEMENT
Apr 8, 2012
I have a table which contains a list of products for a company. They input data about how much stock they have and also the level at which they want to be reminded that they need to order new stock.
[Code]...
I want to list all the true results in a form which the user is then able to navigate through. What would be the best way to go about doing this?
View 2 Replies
Jan 12, 2010
I have two forms receipt and payment. Both are having almost same fields.e.g. entryno, date , partyname, amount. Should I create two different tables for receipt and payment or keep data in single table with additional field 'TransactionType'
View 3 Replies
Jul 23, 2011
I want to select to multiple sql tables using select query in vb.net..I have 2columns in sql table..I have tried this query.. But i'm getting error.
TextBox11.Text = Val(27)
cmd = New SqlCommand("SELECT outside,power FROM vijay21 INNER JOIN vijay22 ON vijay21.outside=vijay22.outside WHERE outside BETWEEN " & Val(TextBox11.Text) & " AND " &
[code].....
View 4 Replies
May 12, 2010
Im not too sure if this is the correct place for this question, but I couldn't find anywhere else..Heres what i want to do. I have two tables in an Access DB. TableA and TableB. Each Table has only one column called Picture, and that column is filled with the names of pictures (picture1, picture2, picture3, etc)
Thing is, that The pictures in TableA have equivalent pictures in TableB. They are not named the same, but the pictures themselves are the same i.e.: TableA Picture1 = TableB Picture3, TableA Picture2 = TableB Picture5.
What i Would like to create is a form that has two datagrids, or Listboxes populated with the data from each table. One for TableA, One for TableB. When the User selects a picture from one of these controls, The other control must show which picture the selected one corresponds to (if i select TableA Picture1, TableB Picture3 becomes selected showing that they match)
I think that most of the work will be at the actual DB, somehow linking each and every field, maybe a one to one link between fields/cells in the DB, then in VB calling that one record that was clicked on, seeing what relation it has to the other table,
[Code]...
View 2 Replies
Jan 13, 2011
How can I use dynamic fields in LINQ in the PART OF THE where query? I mean that I want to write where x = *dynamic fields* I want to do the select query in all of the tables that are in the dataset, not on one datatable.
View 1 Replies
May 2, 2012
Using Visual Basic 2008 express, I would like to access a database with 2 tables, one table (useraccounts) which has Users and Password and ID, and the other table which has information (linktable). Basically I would like to do a login form which reads from the table useraccounts and be able to create new users which will write into the database.
Another is that I have a form with a number of links which I would like to store in the table 'linktable' and it basically just gets the links from the table and straight to the form where it is used. I have tried using access or the .mdf files that visual basic has but I have been unable to find an answer for either.
I wouldn't mind using either access or the .mdf file for the database, I would just like it to work. Overall I am trying to get:
Login form which reads from database table 'useraccounts' and has a new user feature
Just a form that can read / write to the database once the save button is clicked.
View 1 Replies
May 11, 2011
I'm looking for a way to combine a field from multiple tables into a single field in a new table. Because the data populating the tables is coming from an outside source, I would prefer not to change the data in the original files. I have a separate table for each year because this is the way the data is provided. The field layout is not consistent from year to year, but each year there is a field that we'll call "score." I'd like to pull the field "score" from each year's table and have it populate a "score" column in a new table along with the year of the data so that all the years' scores are in the same place. Is there a way to do this using Visual Basic + Access?
View 3 Replies
Nov 17, 2011
I will post a sequence of examples and thought about sql injection, I wish the expert will correct any small mistake in what I will say so I can know exactly the possible danger.
The required is to create a function in vb.net that accept 2 parameter (table_name, fields_list) and return the result in datatable
Now, I am aware of that table_name and fields_list cannot be passed as parameter to the command object using .AddParameter
here is a couple of thoughts, what I would like to know is
1- which function is exposed to sql injection
2- Which function is more safe
Public Class Form14
Dim conn as New SqlClient.SqlConnection(connection_string)
Private Sub Button1_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[code].....
View 15 Replies
Nov 28, 2009
I am using the following code to get all my database fields, I would like to convert one of the fields to Cdbl, not sure how to do that
Dim comm As New OleDb.OleDbCommand("Select * From " & Me.OpenFileDialog1.SafeFileName & " Where Status <> 'S'", con)
I know how to individually do it field by field but i dont want to have to write a select for each field if that makes sense?
Dim comm2 As New OleDbCommand("Select Cdbl([Selling Price]) as SoldPrice, Status From " & Me.OpenFileDialog1.SafeFileName & " Where Status = 'S'", con)
So something that pulls ALL fields and converts one
View 3 Replies
May 28, 2012
It is possible to check two different MySQL tables from the same sub?
For instance:
Dim Connection As MySqlConnection
Connection = New MySqlConnection
Connection.ConnectionString = "server=server; user id=userid; password=password; database=database"
Try
Connection.Open()
[Code]...
What I'm trying to get is something like an "or" function. If TextBox1.Text isn't in the database, then check if TextBox2.Text or TextBox3.Text is in the database.
View 6 Replies
May 14, 2010
i have more than 10 table but same column names i need to collect datas from these table for example i need to select name column from 10 tables how to do this
View 8 Replies
May 3, 2010
there are three tables in dbf , table1,2,3 respectively all are contains similar structure but different data Structure : S.no Quiz Question i want the query which select the Quiz Question/records through user given Range from Textbox1.text to Textbox2.text
View 3 Replies
Oct 29, 2010
I have a form with a list box The code loops through a Tables' row and gives me only one of each of the catergories. If more than one of a perticular item exist it only displays one. i would like to use Select Distinct instead just because it would cut down on the time it would take to read the Rows items and still give me the same results I just am not sure how to write it.
[Code]...
View 4 Replies
May 5, 2010
My project is a standalone application with lots data retrieval and sometimes data update.No SQL server or connection provided)Here is sample code
Dim objDS As New DataSet("Quesetion")
Dim dtBook As DataTable = objDS.Tables.Add("Book")
Dim dtChapter As DataTable = objDS.Tables.Add("Chpater")
[code].....
View 3 Replies
Aug 19, 2010
I have three tables Student, TimeSheet and TimeRecord.
Talbe columns:
Student : StudentId, FirstName,
LastName
TimeSheet: TimeSheetId,StudentId, IsActive
[Code].....
View 4 Replies
Apr 15, 2009
I am looking to select all the tables from a microsoft access database. I just need the SQL statement i think, i can connect to the database that is needed.
View 4 Replies
Jun 12, 2011
in below code there is syntax error in from Clause but i think every thing looks fine iam using access database thx and relation is fine between thes two table
Public Function GetGridData() As DataTable
Dim dt As New DataTable
Try
[code].....
View 2 Replies
Oct 22, 2010
I have used VB (versions 2 - 6) through many years; however, I am crash-course training myself into the VB2008 / VB2010 world kicking a screaming. I would like suggestions as to what SQL database access method should I focus more on in my learning process without making me feel that I'm a million years behind. I know I have WinForms where I can create a datasourse and drag / drop fields or tables on a form to create a grid (not really what I'm looking for).
My trouble isn't so much designing the form but in how I access the database. Theres XML, LINQ to SQL, ADO.NET, and many other methods. Not only do I need to grasp these methods quickly but I also need to know what type of projects I should create. What I mean is...I was thinking that I would design a WinForm app; however, I see that there are WPF apps and others to chose from. This is getting deep. I know it depends on the project that I'm working on. My plans are to write an app based off of either an SQL Express 2008 or SQL Server 2008 database. This first app will be standalone for now but may later become multi-user. I know I'm far behind on my learning curve coming from VB6. I have read a bit on VB2005 / 2008 / 2010. I own
both VB2008 and VB2010. I use VB2008 at work. I know ADO.NET is still alive but by what I read online, it's a dying method and is only kept for backward compatibility. XML and LINQ to SQL and other methods are all pretty new to me.
View 1 Replies
Feb 21, 2011
For my app users can enter a SELECT statement themselves. This can be any select statement at all, it will be mainly used for creating a quick view e.g. SELECT * from table1 LEFT OUTER JOIN table2 on table1.id = table2.id.
Whatever this select statement maybe I load it into a datatable (after checking for no nasty stuff of course) in vb.net. I want to know the table names so I can query the database again for validation purposes on things like datatypes etc.
da.SelectCommand = New SqlCommand(sqlStatement, tempDB.Connection)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
dt = New DataTable
da.Fill(dt)
View 3 Replies
May 18, 2011
For my app users can enter a SELECT statement themselves. This can be any select statement at all, it will be mainly used for creating a quick view e.g. SELECT * from table1 LEFT OUTER JOIN table2 on table1.id = table2.id.Whatever this select statement maybe I load it into a datatable (after checking for no nasty stuff of course) in vb.net. I want to know the table names so I can query the database again for validation purposes on things like datatypes etc.
da.SelectCommand = New SqlCommand(sqlStatement, tempDB.Connection)
da.MissingSchemaAction = MissingSchemaAction.AddWithKey
dt = New DataTable
da.Fill(dt)
View 1 Replies
Aug 23, 2010
I have two tables Employees and CafeLogs. Some employees can be cashiers and also customers at the Cafe shop.
Table structures:
Employees: EmployeeId(PK) , FirstName, LastName
CafeLogs: LogId (PK), CashierId, EmployeeId, Value, => CashierId and EmployeeId are the data from column EmployeeId of Empoyee table
Table relationship:
Employees 1:N CafeLogs (CashierId (FK))
[code]....
Right now I know how to select only LogId, Employee's name, and , Value, not with Cashier name yet.
Dim query = From log In db.CafeLogs _
Join emp In db.Employees On emp.EmployeeId Equals log.EmployeeId _
Select log.LogId, emp.FirsName, emp.LastName, log.Value
View 1 Replies
Nov 14, 2011
I'm currently refactoring an old Visual Basic DLL (VB.Net), which stores all of its data in one module called Globaldefinitions as public fields. There are about 200 fields, referenced thousands of times all around the code:
Public Module Globaldefinitons
Public a As Short
...
Public zz10 As Double
[Code]...
I need to change the module into a class with non-shared fields. This means, each and every of these thousands of references needs to reference the instance of that class:
globalDefinitionsInstance.a = 5
How do I go about this efficiently?
Regular expressions operating on the source fall flat. Refactoring tools like Re-Sharper or CodeRush don't seem to offer this functionality. Visual Studio 2010 cannot do it automatically either.
View 2 Replies
Jun 19, 2011
Class Foo
ReadOnly name As String
Public Sub New(name As String, dependentUpon As Foo)
Me.name = name
[code]....
The output of New Bar() is:
Dependent created. Dependent upon nothing.
Independent created. Dependent upon nothing.
It seems fields are initialized in the same order as they appear in the source code, which (a) leads to an unexpected result, and (b) seems a little puzzling, given that one is normally not permitted to read from uninitialized variables in .NET, yet that seems to be working fine above.I would've expected VB.NET to be smart enough to initialize referenced fields first, and only then those that reference it; i.e. I'd have liked to see this output instead:
Independent created. Dependent upon nothing.
Dependent created. Dependent upon Independent.
how to get VB.NET to behave like that instead, without simply having to swap the declaration order of dependent and independent inside class Bar?
View 1 Replies
May 27, 2012
I'm trying to create a table in Word using data from a table in Access. There are four fields in the access table that I need. 3 fields are text which I can populate the Word without any issues. However the fourth field is a memo with >255 characters.I'm struggling to come up with the proper code to allow me to populate the Word field with the memo data that has more than 255 characters. The code I have so far is listed below. But when it hits the memo field, it crashes on the line I marked with **. I know it's not text, but I've tried many different field types, but nothing has worked so far.[code]...
View 1 Replies
Jan 14, 2012
My intent is to have the code - on a button.click event - check the Username and Password fields and return an error depending on which is wrong. Or if both are wrong, return a different error message. I've set the username as parts and the password as parts (still learning how to use external authentication). [Code]
View 2 Replies
Aug 17, 2010
I have several sqldatasources for my gridview. All of the columns are autogenerated. However they all have some consistent fields and I'd like to make those fields template fields so I can modify the edit template for them such as adding a drop down menu. Is this possible?
View 1 Replies
May 7, 2010
i want to take a comma delimited text file and then select all unique records based on one of the fields in the text file. should i read the text file into a data table or just use a data reader?
View 7 Replies
Jul 25, 2012
I am using VS2008 and SQLite. I have created a database and several tables and am attempting to populate the tables with data from arrays.
The following code (example) works fine but stops after it inserts 30 to 50 records. I am running the VB code in debug mode and when it stops, I press pause to see where it is. It stops on "SQLcommand.ExecuteNonQuery()" and when I press continue (F5) it will insert another 30 to 50 records.
I do not get an error message. Is this a timeout issue? How do I keep the loop running to the end of the array?
Following is example code.
Dim
SQLconnect As New SQLite.SQLiteConnection()
Dim SQLcommand As SQLiteCommand
CODE:.....................
View 4 Replies
Jul 12, 2011
have a datagridview containing 2 tables left joined, so that:table1 LEFT JOIN table 2 ON table1.id=table2.idI get an error whenever I try to edit my datagridview."invalidOperationException was unhandled by the user codeDynamic SQL generation is not supported against multiple base tables."The error points to this line:
da.FillSchema(dt, SchemaType.Mapped)
da.Update(dt) << This line
'da = dataadapter
[code].....
View 3 Replies