Database - Compare Two Fields In An SQL SELECT Statement To Then Select Other Fields Based On This Result?

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


ADVERTISEMENT

Take A Comma Delimited Text File And Then Select All Unique Records Based On One Of The Fields In The Text File?

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

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

SQL Injection : SELECT Fields FROM Table

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

VS 2005 Select All Fields And Cdbl For One?

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

Compare .net Objects To Fields In A Database?

Jun 16, 2010

I have a connection string set up and a data reader.I have two textboxes on my form for users to type in. One textbox (txtLogin) is a user name and the other textbox is a password (txtPwd). I'm trying to compare what a user types into those two boxes to a table in a vfp database. The table I'm trying to compare to is open about 99% of the time so I need to be able to read from it in some type of "shared" mode.

My Select statement needs to be something similar to "select * from sites where clogin = txtLogin.text and cpassword = txtPwd.text"I just don't know how to get this to work properly.

View 2 Replies

Select Statement That Uses Variable Result To Textbox

Jul 31, 2010

I'm relatively new to VB. I want to perform a SELECT statement that uses a variable to return a value, example;
mysql> SELECT room_description FROM room_descriptions WHERE current_room = 'someVariable';
And display the result in a TextBox i.e. TextBox.text = someVariable.
So how do I perform a query from VB that passes a variable? How do I assign the result to a variable?

View 3 Replies

Check When OLEDB Returned A Result From SELECT Statement?

Nov 25, 2009

In my .NET application I have to get results from a MS Access database. I would like to add error checking to make sure a row was returned from my SELECT statement.

View 1 Replies

Database - ID Select ,select Statement?

Mar 23, 2012

have a table with following fields

Emp_id varchar(50)
Emp_Name varchar(50)
Emp_surname varchar(50)

[code].....

View 1 Replies

Select Case Statement Based On Data Type

Oct 20, 2009

I want to be able to have a case for each data system data type. Obviousely the code below doesnt work but it should make it easier to understand my question.

[Code]...

View 4 Replies

Use A Select Case Statement That Evaluates PostDiscountCost Based On The Value 0 To 999.99?

Oct 1, 2011

I need to use a select case statement that evaluates PostDiscountCost based on the value 0 to 999.99, 1000.00 to 1499.99, 1500.00 to 2499.99 and one that doesn't fall within the others. The message box's going to be triggered by the vbYes in the confirm exit message box. Im not asking anyone to do it for me, I just have no idea where to start it, if I need to declare anything else and if I'm on the right track. Code Attached.

View 1 Replies

Compare Two Access Databases With Two Fields Each And Write The Results To A Third Access Database?

Apr 22, 2010

I am using the code shown below to compare two Access databases with two fields each and write the results to a third Access database. I am getting an error at the "Do While DMReader02.Read = True" line: "Invalid attempt to call Read when reader is closed." Why would the reader be closed at this point if I am using different DataReaders in the two loops?

Imports System.Data.OleDb
Partial
Class Form1

[code]....

View 2 Replies

Compare The Date Fields?

May 26, 2010

I have 2 Textboxes with Date/Time in them. I want to test if one is less than the other, here is my current code

Dim StartTime1TextBox As TextBox = TryCast(FormView1.FindControl("StartTime1TextBox"), TextBox)
Dim EndTime1TextBox As TextBox = TryCast(FormView1.FindControl("EndTime1TextBox"), TextBox)
If Not [String].IsNullOrEmpty(StartTime1TextBox.Text) Then

[code]....

However if I enter an Start time of 9:00 AM and an End Time of 5:00 PM this triggers the isvalid=false because 5 is less than 9. Doesn't look like it's comparing the date and time just number.

View 4 Replies

Refactoring A Module Into A Class: Changing Shared Fields To Instance Fields

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

Can The Initialization Order Of Class Fields In .NET Be Influenced By References To Other Fields

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

Create Word Form Fields With Memo Fields From Access?

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

Validating Login Fields - Check The Username And Password Fields

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

Gridview Combine Autogenerated Fields And Template Fields

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

Use A SELECT Statement To Select All Data?

Apr 2, 2009

I need to use a SELECT statement to select all data under a column name (like all employee names) and then to add the values to a listbox.

I usderstand that the select statement must be:

"SELECT * FROM EmployeeTable WHERE EmployeeNames LIKE *" (at least I think)

but then what? combobox1.fill ("EmployeesTable") ?

View 9 Replies

DB/Reporting :: Select Statement To Retrieve Data From .csv File Database?

Jan 29, 2010

I am using the following Select Statement to retrive data from my .csv file database:

Code:
Dim comm As New OleDb.OleDbCommand("Select *, Left([Street Full Address], IIF(InStr(12,[Street Full Address],'-')>0, InStr([Street Full Address],'-')-1, Len([Street Full Address]))) as StreetFullAddress From " &

[Code].....

View 4 Replies

.net - Disable A Button Based On Three Textbox Fields?

Dec 13, 2010

I'm quite new to VB.net (and VS 2008), so I'm afraid my question might be basic, but I'm not sure how to solve it.I have a winform with three textbox fields and a button. All textbox fields must be filled before the user can click the button to continue. To this end I would like to disable the button as long as there is at least one empty textbox.

If I had only one textbox field, it would be easy for me to do. In the Textbox1_Leave event I would check if Textbox1.Text is not empty and if so, set Button1.Enabled = True.But what should I do if I have three textboxes? Have three event handlers, one for each textbox? Or is there a way I'm not familiar with?

View 4 Replies

ASP.Net Auto-populate Field Based On Other Fields?

Nov 15, 2010

how i can implement below requirement using asp.net and vb.net.I have three fields in a form which are filled by users. Based on these three values, i need to auto-populate the 4th field.I have planned to implement this in the following way.Write a separate class file with a function to calculate the possible values for the 4th fields based on 1st 3 inputs. This function can return some where between 1-10 values. So I've decided to use drop-down for 4th field, and allow users to select the appropriate value.Call the above function in onchange function of 3rd field and take and use the return values to populate the 4th field. I'm planning to get the return values in array field.(Does this need a post back?)

View 3 Replies

Renaming Files Based On Dataset Fields?

Nov 7, 2011

I apologize if it is not. I am trying to write a script in Visual Studio 2008 (using a VB project) that will, upon the clicking of a button:

- A file object will be created.

-Said file object will read in a number of files from a specified file path.

-A dataset will be created and populated with fields from two columns within a database table; app_id and company_name.

-The script will read through the file names and fields recorded in the dataset, renaming the file to the app_id if the original file name contained the company_name.

The code I have so far to do this:

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'Create the file object
Dim objFSO

The problem is that currently this code will only rename the file if the file name and company_name match exactly, ideally I'd need to include a clause to make it rename if the file name is "LIKE" or "contains" the company_name.

View 4 Replies

.net - Using Select Statement From 1 Database To Insert Into Another Database Using .NET?

May 1, 2009

I am currently writing a VB .NET application where I am trying to open 1 database, create a select statement and then post the results into another database file using Microsoft Access database 2003.

The code seems to stop executing at the statement cmdJetDB.ExecuteNonQuery()

I am using the following code:

Dim conn1 As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:Sample.mdb")

Dim conn2 As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:db2.mdb")
conn1.Open()
conn2.Open()

[Code]...

Question: What is it that I am not doing. I opened both connections, stated my two SQL statements, yet it is still not working. I really need to get this application working. Please Help.........

View 3 Replies

Use SELECT Statement To Retrieve Data From An Access Database And Display In A Textbox?

Sep 3, 2010

I am trying to retrieve information from one row that has four columns(name,company,address,phone) so that once it is displayed in 4 different textboxes, I can transfer to a word document.

View 2 Replies

Access To SQL Server Based On Fields Selected In ListView?

Jun 4, 2011

I am required to send MS-Access table to SQL Server Database, based on fields Selected in Listview.

1)Till now i am able to get Access table names and their field in List view.

2)I am able to check whether database exists and Whether table exists in SQL Server with same name from VB.Net.Now i don't know how to insert Access Tables based in Fields Selected in ListView to SQL Server.

View 2 Replies

RegEx - Extract Fields And Data Types From SQL Statement

Jul 9, 2009

I have this sql statement:
CREATE TABLE [dbo].[User]( [UserId] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [MiddleName]
[varchar](50) COLLATE SQL_Latin1_General_CP1_CI_A

What I want is regex code which I can use to get all fields and data type. So will return something like that:
FirstName varchar
MiddleName varchar
The sql statement will always have this format. I am using .Net to run this regex

View 2 Replies

C# - MS Word Office Automation - Filling Text Form Fields And Check Box Form Fields And Mail Merge

Sep 3, 2009

experience on how to create an engine using C# (VB.NET is okay too) that is generic enough to handle most cases of MS Word text fields I need to fill with data I'm getting from a database? In short, I'm about to embark on this little Office automation excursion and I'm hoping a little bit of feedback here.

View 2 Replies

.net - Assigning Table Fields To Objects Within Form Based Off Of Count?

Apr 9, 2009

i saw jim example in the codebank and i added the percent progress parameter to report progress method (to change the progress bar value)this is jim example:-

vb.net
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, _
ByVal e As DoWorkEventArgs) Handles BackgroundWorker1.DoWork

[code]....

View 2 Replies

Creating VB Code To Increment The Number Of Fields In An SQL Create Table Statement

May 8, 2012

I have an SQL statement which i need to code in vb:

CODE:

Notice the fields prodno1 and prodno2 in the table structure.. this is part of a number of sql statements i need to run and put inside a loop. my problem is i want to automatically use this same code such that on the next loop, this sql statement is going to be:

CODE:

Note that in this "2nd loop"

- the table name is now r3 from r2 in the first SQL statement
- there are now prodno1, prodno2 and prodno3 instead of just prodno1 and prodno2
- in the WHERE clause, the p.prodNo becomes p.prodNo2

And so on and so forth.. so for the 3rd loop

- there's going to be r4
- there's going to be prodno4
- in the WHERE clause i will use p.prodNo3

View 3 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved