[2008] Sql Select Query?
Jan 19, 2009
I'm tying myself in knots with AND OR NOT qualifyers to return all rows having two different items. From a column headed 'Instrument' I want to retun 'CELLO' and 'VIOLIN' Where am I going wrong with the following?
View 8 Replies
ADVERTISEMENT
Jul 10, 2009
Scenario: Writing a scanning program, thing is I can't have duplicate file names(which I generate). The img file paths r saved in a database.I'm trying to write a function that will return all the records I need using a SQL SELECT. To make this work I need to put all the retrieved records(just the one field from the database) into an array.My Problem: I have no idea how to put the retrieved SQL query into an array and then return it.
Private Function fileNameAcquisition(ByVal path As String, ByVal id As Integer) As String
Dim conn As New SqlConnection
Dim dr As SqlDataReader
[code].....
View 3 Replies
Jan 7, 2012
My DATE field always display with time in vb.net is there a select query to format it into yyyy-MM-dd?
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
Jul 16, 2010
I'm trying to get a simple count of rows meeting some criteria. The value returned does not coincide with the correct number of rows when running the same query in Management Studio (SQL 2005)
vb.net
Public Function RowsAffectedCount() As Integer
Dim result As Integer = 0
[code]....
'result' always returns 1, but I have 3 records meeting that criteria in the database. Been staring at the code for a couple hours now and can't figure it out... I just need to know if the Count of rows returned from a SELECT statement is greater than 1 (at least two records).
View 9 Replies
Mar 16, 2009
I have an ado.net statement I want to convert to use NHibernate:
Dim sql As New StringBuilder()
sql.AppendLine("SELECT r.RoleId, r.RoleName ")
sql.AppendLine("FROM dbo.aspnet_Roles r ")
[code]...
View 1 Replies
Nov 20, 2011
I have pulled information from a database into a datatable (dtCustomerInfo) then I expanded on the columns by processing the data and I can display this in a datagridview without any problem. However, the data is in detail and I want to ultimately summarize by customer name.The code below has a commented sql statement that is the statement I ultimately want but it is not working. However, the idea is that I want to Select from one datatable into another but run aggregate sum on several columns so that I will get one record per customer showing totals for each column.So I broke it down to just pull all data possible into the second table.[code]I do know the grouping in the current select * statement does nothing but my issue is more that the columns do not show up.
View 3 Replies
Feb 21, 2011
On an SQL query I have. I have the select query working fine but according to the result I need to set the column of a table to 0. I have the following Select query:
CODE:
So where the CommissionCalculator SetUp > 0 I want it to Update the CommissionStructure SetUp column to 0. I was thinking I might need an IF statement but I dont know how to work with them in SQL.
View 7 Replies
Sep 18, 2009
class:
Public Sub insetTotalPaidAmt(ByVal dtSDate As Date)
Dim comm As OleDbCommand
Try
strQry = "INSERT INTO rpt_Paid_Amt(ST_ID,ST_PAY_AMT,ST_DIS_AMT) " & _
"SELECT S.ST_ID,SUM(P.PAY_AMOUNT),SUM(P.PAY_DIS) " & _
[Code]...
View 1 Replies
Mar 14, 2012
how to select multiple table in vb2010? i trying to create a login so i need to retrieve the data in 3 different tables in one database i have a code but not work.[code]
View 2 Replies
Jun 21, 2010
Linq to SQL query to Select the maximum "MeanWindSpeed" value? The database name is "WeatherArchives" The TableName is "TblValues" The Column is "MeanWindSpeed" And Also, I would like to have a query to get me the Max "MeanWindSpeed" in each year,
View 1 Replies
Feb 6, 2010
i have a project which is room scheduling. i'm having a problem on how to make my query to be able to select the available rooms for the givin time start and time end.
View 14 Replies
Mar 30, 2010
I am trying to link to a Access database at runtime using a SELECT FROM WHERE query, which I can do but.......
with the WHERE part I want to select several conditions, 4 actually and it is not working, what am I doing wrong?
Here is my code,
Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=V:GYMDBFLineProdSanderProduction.mdb")
[Code]....
View 2 Replies
Jun 7, 2011
Public Shared Function getrealrequests(ByVal itemname1 As String) As ArrayList
Dim sqlStr As String = "data source=localhost;initial catalog=Customers;integrated security = true"
Dim dbRecords As ArrayList = New ArrayList
Dim dbConn As SqlConnection = New SqlConnection(sqlStr)
[Code] .....
I'm trying to pass the value of 'itemname1' to the select query. What's the correct syntax to get it to work?
View 6 Replies
Jan 4, 2012
I've a collection with the data like this.[code]...
how can select the distinct data using linq?
View 2 Replies
Nov 2, 2009
Dim MyQuery = From c In xdoc.Descendants() _
Where c.Attribute(OriginY) IsNot Nothing _
Order By Val(c.Attribute(OriginY).Value), Val(c.Attribute(OriginX).Value) _
Select c.Attribute(UniStr)
Right above you can see my First! linq attempt! And here comes my first question.
How can i select more than one column in a linq query in vb.net?
For example... Select c.Attribute(UniStr) AND c.Attribute(OriginY)
View 1 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
Mar 30, 2009
The data type for my DATE column in SQL is smalldatetime. I want to perform a query which selects records based on the the selected date of a calendar object.
A user clicks on the date and the date is stored in ddlfilter2 DDLfilter2.Items.Add(CalendarMain.SelectedDate)
mystring = "SELECT * FROM view_main where date" & "='" & DDLFilter2.Text & "'"
produces this "select * from view_main where date='24/03/2009'
I then get an error saying "The conversion of char data type to smalldatetime data type resulted in an out-of-range smalldatetime value."
In the SQL database the data is displayed as "24/03/2009 00:00:00" is this why the query is failing?
View 1 Replies
Jun 11, 2011
I am using VS 2010, SQL 2008 express and doing windows applicaion programming in vb.net.I want to write a select query(or Stored Procedure) such that the conditions mentioned under WHERE clause can be variable .like :Select * from TABLE where F1 = var1 and F2 = var2 and F3 = var3.Now on the basis of some conditons the equations in where clause should beused.Say condition is variable value >6.Now in this case ,if
var1 =7 var2 =3 var3 = 8 then the query shud behave like
:
select * from TABLE where F1 = var1 and F3 = var3
[code].....
View 1 Replies
Sep 6, 2009
I have a table with these columns:
IDsales, salesDate, salesmanID, itemDesc
I need an SQL querry to select all the sales from a certain date, with the summed sales grouped by salesmanID. The problem with the querry is that the data in the salesDate field is in a long format (with dd/mm/yyyy hh:mm:sss) and I dont know how to set the querry to disregard the "time" info, and take in account the "date" part only.
View 5 Replies
Sep 15, 2009
My following code is only retrives number month(1,2,3,4....12)and not month name(January,February,.....December).Before that i had try using function datepart, Monthname and date_format but i still din get my answer.[code...]
View 3 Replies
Mar 21, 2011
I have this query which I want to submit after the user click a button.
Update tbl_books Set Bk_Rent = Bk_Rent - 1 Bk_Avl = Bk_Avl + 1 Where Bk_Id = ( Select * from tbl_transactions where Trans_Id = @a )
The problem is as far as I know, Update and Select queries have different formats. Update statements will use the ExecuteNonQuery()while Select needs a dataset. My problem is how can I execute these two statements at the same time. I tried this code but it didn't work out.
Dim command4 As New OleDb.OleDbCommand
Dim adapter4 As New OleDb.OleDbDataAdapter
Dim dataset As New DataSet
[Code].....
View 9 Replies
Jun 21, 2010
I have created a SELECT FROM WHERE query to perform a search here is my code:
SELECT EmployeeID, DepartmentID, Forename, Surname, Role, Email, Telephone, Extension, Mobile, Photo FROM Employees
WHERE (Forename = ? or ? = '') and (Surname = ? or ? = '') and (Role = ? or ? = '')
I have then put the folllowing code to rung the query within my form:
Me.EmployeesTableAdapter.FillByName(Me.myDataSet.Employees, Me.ForenameTextBox.Text, Me.ForenameTextBox.Text, Me.SurnameTextBox.Text, Me.SurnameTextBox.Text, Me.RoleTextBox.Text, Me.RoleTextBox.Text)
When i search by forename or surname it works fine but when i search by role i get this error..oledbException occured No value given for one or more required parameters.
View 1 Replies
Dec 6, 2008
I have a stored procedure that I need to be able to change the table name that the select statement in the stored procedure uses depending on a user input, however I am having a problem with the code:
Code:
CREATE PROCEDURE [dbo].[spQryParentComments] @projTable as varchar(50)
AS
[code].....
View 3 Replies
Feb 12, 2011
I am using VS2010 windows application , SQL server 2008 express at backend.I am designing a windows form with fields to search records in database.Say there are 3 fields in the form :
1) material no 2) material group 3)creation date the corressponding table in database with above fields is " Material_master" User can search materials in the database by entering any of the above fields.No I want to write a query where if user doesn't enter anything then my query should work like
"select * from materialmaster "
if only material no is enterd at screen then
"select * from materialmaster where MatNo = materialno "
if both date of creation and material no enterd then
" select * from materialmaster where MatNo = materialno and Date = creationdate "
In other words , field with no values in it should not be accounted in the where clause. Only one query I want to write.How we can achieve this in VB.net windows application?
View 4 Replies
Feb 16, 2010
Using vb2005 and .Net 2.0. I've been trying for some time to get my query to work. I've posted my issue on several forums but no one been able to asssist me. From code behing I need to query Active Directory and have following issues:
1. I need to select only where "title" is empty and
2. I need to do a LIKE on sAMAccountName
[Code]...
View 2 Replies
Jun 18, 2009
There is a Select overload that adds an index to each element of a sequence :
[Code]...
Can this query be written in Query Notation ?
View 1 Replies
Jun 15, 2011
I have to retrieve data in two TextBoxes but the data should belong to tokennum that I am getting from first text box. I have a total of three TextBoxes and one button. In a database called db1 I have a table named Table1 and two fields ser as serial number, tokennum for token number and name for name of employees.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As New OleDb.OleDbConnection
[Code]....
View 2 Replies
Mar 11, 2010
CODE:
And the following sub routine is load in the Listbox_selectedindexchanged event
CODE:
And listitem class
CODE:
And subsequently I want to Design the select query by adding the three column i.e. First Name, Middle Name and Last Name in the Listbox and by selecting the list item that will show in text box.
View 19 Replies
Jul 8, 2009
I want to make a report with a query "Select * from StudMaster where StudID IN ('S0001','S0002','S0003')"For this I created a parameterised command object in data environment and set the query as:Select * from StudMaster where StudID IN ( ? )
Then I called in vb code as:Dataenvironment1.command1 ("'S0001','S0002','S0003'")
Is there anything wrong in it? It is not working..Plz help me out, how can I make it run.
View 4 Replies