Sql Database Passing Random Row Choice To The Other Subs?

Jan 7, 2012

i have an sql database in my application and everything is working fine apart from one aspect.My random row picker code is located in one button on_click event. Is there a way of passing it over to other subs/on_click events?

[Code]...

View 1 Replies


ADVERTISEMENT

Random Row Choice From Sql Database In Vb

Jan 6, 2012

I have created a small sql database using new data source. i have placed buttons to move to next,previous,first and last row but i am wondering if there is a way of making a button which would randomly pick a row with information from database or just make it randomize them before they are appearing on the screen.

At first i have tried creating random number generator and then joining it with the coulmns in the database. I failed in the end even though i thought it was going to work. Then i thought maybe i have to change the query as in, instead of "Select that and that and that from database" i thought i have to write "Select that and that from database sort by rand", i also saw that some people write limit 1 or more afterwards but i have no clue what it is and didnt use it. Anyhow i tried that query and it didnt work.

EDIT: I also thought about adding all questions into array, or use some sort of indexing, but i have to use database as the requirement.

Also if anyone would be willing to give me an advise of what is best book i could buy, which would cover databases in sql and some beginner/intermediate programming in visual basic.

View 1 Replies

Forms :: Passing Variables Between Subs?

Sep 2, 2009

I'm having an issue where I need to pass the value in a variable from one sub to anotherHere is the scenario. I have two forms; Main_Form and frmClient. I take a value from frmClient and pass it into a sub called Form_Activate located in Main_Form. I then need to take the value from Form_Activate and use it in a sub called when the user selects a menu item in the toolstrip.Starting point is frmClient and the code there is this:

Private Sub Button1_Click(ByVal sender as System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Client As Integer

[code].....

View 9 Replies

Random Choice Change Of Text Box?

Apr 21, 2010

Like how can i make it so it changes the text box to anyone of these words randomly

bob
somethinghere
somethinghere
somethinghere

[code]....

View 4 Replies

Multithreading - Passing Variables In Shared Subs?

Apr 23, 2012

Public Shared _formRef As frmMain
Public Shared f As frmMain
Class Server[code].....

but once firing off the code i get the error you see in my image attached.

View 1 Replies

Passing Subs And Functions With Varying Signatures Into A Class

Dec 28, 2011

I have a number of unrelated subs and functions that do various things on my server (e.g. Lighting control, data caching, server maintenance, etc). They are all in various classes which I have coalesced into a single solution.My goal is to create a single, simple interface which each of these disparate classes can be integrated and called from a command line interface. Instead of hard-coding a longish case statement which parses arguments and passes them to the various subs, I wanted to make a generic class which can be instantiated with a minimum of information and put into a data structure. Ideally, adding a new function would involve:

1.) Providing the function pointer (Delegate). The delegates will have various signatures. This is the crux of the question.

2.) Providing ancillary info such as the command-line callable name, number of arguments, argument types, etc.

I have a 100% working class called "node" which is basically a hierarchical tree of node instances. I can use this to simply organize function calls in related branches. All is working quite well.NodeFunctionDelegate(ByVal args As String) As String.The node takes the arguments passed to it by the command line and sends it as the "args" string as comma-separated. The delegate function then needs to know how to split up these comma-separated values, type them, tryparse them and etc. It then must return some string.It works, but it involves writing a middle-man function stub which can receive the argument string from the node class, do the parsing and type checking, and then call the destination function.My goal is to eliminate this trivial middle-man function. The problem is, I can't figure out how to create a variable-signature delegate for the node class.

View 9 Replies

VS 2008 "Pacman" Ghosts Random Direction Choice?

Nov 20, 2009

I've got a small pacman-like game where ghosts are running around a maze. At the moment, their movement is completely random. Each step, they determine which directions they can possibly move in (taking into account walls), and then they choose, randomly, one of those directions.Now, this works, but it's not very good. If a ghost is in a long corridor where he can only move up or down (or left/right), then he will usually not go anywhere, but just move up, down, up, down, down, up, up, down, up, etc. So, while it does move every step, in the long run it doesn't go anywhere.

View 7 Replies

VS 2008 4 Drop Down Lists, Select A Choice In One, All Get Same Choice?

Mar 12, 2010

I have four drop down lists here and I've assigned the datasource and displaymemberproperties so they are populated by a table. When I run the program and select a choice, all four of them get updated with the new choice.

View 3 Replies

Calling Private Subs In Another Private Subs?

Jun 15, 2009

I'm trying to call a private sub in another private sub. For example ;

[Code]....

View 13 Replies

VS 2010 Add Subs / Functions To Subs / Functions?

Oct 26, 2009

When you refrence a Function like this one:[code]You may want to be able to get more out of that, like this.[code]So how would I be able to add subs or functions onto a sub or function like that?

View 4 Replies

Passing Value From Database To A Variable?

Nov 15, 2011

how to pass value from database to a variable.

This is my query:
Dim it As String = "Mouse"
Dim itNo As String
SELECT * FROM tblITEquipmentName WHERE equipmentName LIKE '" & it & "%'"

I would like to get the ItEquipmentNo and pass it to variable itNo

View 7 Replies

Asp.net - Passing A Database Value To A Front-end Querystring?

Nov 16, 2010

This may be a simple question, but I'm trying to call a a value from table in my back-end SQL Server database and pass it through a querystring in the URL. For example:

I'm building a mobile web site that registers a mobile device to an account on the sign up page. After the database entry is created, I want the to get the generated deviceId from the database and pass it to a querystring in the URL such as: http:[url]....

View 1 Replies

Passing Input Box Values To A Sql Database?

Feb 23, 2011

I have an input box that allows users to enter a date that when the user clicks "Ok" that it does two things, marks a field called "code" in my Exceptions SQL table as H and passes whatever date they have entered to that table as well.

View 1 Replies

.net - Passing A Unfilled Value In Database Using Insert And Update?

Nov 7, 2010

i has one problem in which i can enter some of a data to the database.Ho can i code this things..i used Insert and update query....the value is type double,integer...and also string.....

View 1 Replies

.net - Passing Parameter To Query For Access Database?

Sep 19, 2011

I am using following code and trying to get data by given parameters. I donot know how to pass the parameter value to my query.

[Code]...

View 3 Replies

Passing Values Into Access Database Using String

Nov 2, 2010

I am a total beginner to Visual Basic and have a project to conduct a survey for my company. The Answers of the users need to be populated to the database. So far, all I've managed to do is to define a string which will have the answer to be updated into the access table. How am I supposed to pass the value?

View 2 Replies

Add A Random Number Into A Database?

Jan 14, 2010

I'm wanting to add a random number into a database but before I do this I want to check to see if I alreay have this number in there, How can I do a search to return a true or false I guess answer to if the value is in my access database?

View 22 Replies

Write Binary Files Or Passing Data Into Database?

Nov 2, 2009

What do you think what is faster:

1. writing 1000 records in a binary file on a server? or

2. passing the same 1000 records in a database on a server?

and

1. search a specific record in a binary file? or

2. search the same specific record in a database file?

View 2 Replies

Random Code In Database Recorde?

Jan 24, 2011

i am serching for the random code for database the name of the table "q"

the fields
qu = label "the qustion"
an1 = button " answar 1 "
an2 = button " answar 2 "
an3 = button " answar 3 "
an4 = button " answar 4 "

[Code]...

View 1 Replies

Regarding On Random Select Record From The Database?

Jun 3, 2009

As in today i click on the button it will display the item when i hit again the button it will still display the same item and last for the whole. On the second day, i hit the button again it will display other items and last for thewhole day again.

[Code]...

View 1 Replies

Select 1 Random Records From Database?

Feb 15, 2012

I just want to select 1 random record from my database for example in my table1 i have a,b,c,d,e,f,g then everytime i click the button in my program it will output randomly between a to g then i can add another record from my database and if I make it a to x it will randomly choose between a to x, the random doesnt have any conditions.

Right now i've found some codes that will be very useful but i cant modify it so it will be connected to my database.

Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DT1 As New DataTable
DT1.Columns.Add("SN1")
DT1.Columns.Add("NAME1")

[Code]...

View 2 Replies

DB/Reporting :: Error While Passing Access Database Values Into Dataset

Sep 23, 2008

Trying to make a vb.net program that is able to read values from an access database and pass them into some data sets. Here is the code I have so far, with the error line between the two dotted lines:

[Code]...

View 1 Replies

How To Generate Random Images From Access Database Using Hashset?

Jun 22, 2010

I am trying to generate random images from access database using hashset as it is said to be unique and there won't be any repeated images appearing. But, it doesn't seem to work.

How can i get it to work? By the way, i am very new to the concept of hashset.
Private Function GetImageFromByteArray(ByVal picData As Byte()) As Image
If picData Is Nothing Then
Return Nothing
End If

' is this is an embedded object?
Dim bmData As Integer = If((picData(0) = 21 AndAlso picData(1) = 28), 78, 0)

' load the picture
Dim img As Image = Nothing
Try
Dim ms As New MemoryStream(picData, bmData, picData.Length - bmData)
img = Image.FromStream(ms)
Catch
End Try

' return what we got
Return img

End Function

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Panel1.Visible = False
Panel2.Hide()


Dim conn As New OleDbConnection
Dim DA As OleDbDataAdapter
Dim DS As New DataSet


conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db1.mdb;User Id=admin;Password=;"

DA = New OleDbDataAdapter("Select Empty, EmptyName, Target, TargetName from PicturesDisplayed", conn)
DA.Fill(DS)

Me.PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage


Dim oledbconnection As OleDbConnection
oledbconnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:Documents and SettingsAdministratorDesktopdb1.mdb;Jet OLEDB:System Database=system.mdw;")

oledbconnection.Open()
Dim command As OleDbCommand
command = New OleDbCommand("select count (*) from PicturesDisplayed", oledbconnection)
Dim count As Integer
count = command.ExecuteScalar()
oledbconnection.Close()


Dim randomImage As New HashSet(Of Integer)
' Create a integer and new Random object
Dim intPic As Integer
Dim rand As New Random

'Pick a random number between 0 and the number of images in database
intPic = rand.Next(0, count)
randomImage.Add(intPic)

PictureBox1.Height = 256
PictureBox1.Width = 256

PictureBox2.Height = 256
PictureBox2.Width = 256


Dim pic1x As Integer = _
(Me.ClientSize.Width - PictureBox1.Width) 2
Dim pic1y As Integer = _
(Me.ClientSize.Height - PictureBox1.Height) 2
PictureBox1.Location = New Point(pic1x, pic1y)


Dim pic2x As Integer = _
(Me.ClientSize.Width - PictureBox2.Width) 2
Dim pic2y As Integer = _
(Me.ClientSize.Height - PictureBox2.Height) 2
PictureBox2.Location = New Point(pic2x, pic2y)

' Now set the picturebox image equal to the image chosen from the array randomly using the random
PictureBox1.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(intPic).Item(0))
PictureBox1.Visible = True
PictureBox2.Image = GetImageFromByteArray(DS.Tables(0).Rows.Item(intPic).Item(2))
PictureBox2.Visible = False


If (randomImage.Count = count) Then
Me.Close()
End If

End Sub

View 1 Replies

DB/Reporting :: Alter A Column In An Acces Database To A Random AutoNumber?

Mar 3, 2008

I'm wanting to alter a column in an acces database, to a Random AutoNumber I know how to do it for incremental e.g."ALTER TABLE MyField Counter(1,1)"but how do you do it for a Random Autonumber??

View 10 Replies

Sending 'mypassword' To Database Send A Random Collection Of Letters And Numbers

Oct 21, 2011

So in my program I have a database where I send info such as passwords, is there any way to (in an easy way) encrypt the password before sending it so instead of sending "mypassword" to the database I send a random collection of letters and numbers like "shH3n2ja"? I only need two functions, encryptPassword, decryptPassword.

View 7 Replies

Visual Studio: Databinding With Random Control In Database (SQL Server 2008)?

Feb 29, 2012

i have this database format in SQL:

ID name add num
1 fel mn 201
2 john kaye 23
3 Kate mani 25

I used databinding to call the values on (SQL) to textboxes in visual studio 2010 and i have this code in NEXT command:

Inter is the name of the databinding
With inter1
If .Position = .Count - 1 Then

[code]....

The code above display the information not on Random. How can i display those information in Random mode? And i need a msgbox when all the data has been already seen by the user. I mean no redundant data will be seen by the user upon random mode has been done.

View 8 Replies

Choice For Server Applications?

Apr 8, 2009

I am about to start developing my second application in VB2008. The need is that it has to run on a network enviorment, probably under windows nt, the database has to be on the server so everybody uses the same data. The database is suppose to contain a lot of data on many tables, whatīs the ebst way to go? Access, SQL, foxpro dbf? Also what kind of project am I suppose to start? a windows app? or some kind of .net app.? I am sorry if I am saying dumb stuff itīs just that I am a rookie. Have in mind that after I build the application, many users have to have access to it from different computers and I also want the database to be availbale for a future website with forms and queries and stuff taken from the same database, is ASP the best choice for that purppose?

View 6 Replies

Display Choice Of Forms?

May 20, 2009

I'm developing a form that displays conference attendee data.I have a panel control on this form and would like to put a series of buttons at the bottom of this form that will open other forms in the panel. So for example, there would be a button to open the Address form, another button to open the Email form, and so on.There will be 10 buttons total. I have the Address and Email forms set up so far and it seems to work pretty slick.

Before I go any further, is this the best way to do this? FWIW, all forms will have a datarepeater control on them since there can be multiple addresses per attendee, multiple emails, etc.

View 9 Replies

Menu Choice Not Being Found

Feb 17, 2011

I have a combo box which is set up with the follow properties and is populated with data and one blank row.

DropDownStyle = DropDownList

sometimes i get a message box even thought something is selected, what could be wrong?[code]...

View 4 Replies

Set ComboBox Choice As Variable?

Feb 17, 2009

I made a combo box and i need to know how to set one variable for each choice in the combo box. for example, my choices are poor, average, good, and superior. I want to set the "poor" variable as the poor option in the combo box and the "average" variable as the average option in the combo box and so on and so forth.

View 3 Replies







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