473,396 Members | 1,783 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,396 software developers and data experts.

getting the state id

Hi.. how to get the state_id from the tab_states table. i am selecting the state_name from dropdown list and i have to insert the corresponding State_id value to a tab_city table. i am getting the state_name in drop down list. but while saving it is not taking the state_id..
i am a beginner. so can u please help me to do that coding??? i will give the description of my work.

state name -> i am selecting from a tab_states table(dropdow list)
city name -> i am entering to a textbox.

while saving it should save the state_id of corresponding state_name and city_name to tab_city table.

tab_states table description

state_id
state_name

tab_city table description

city_id
city_name
State_id

The coding which i have done is given below

Dim ds As New DataSet
Dim stateid As New Integer
con.ConnectionString = "Driver={Microsoft ODBC for Oracle};server=dbserver;uid=kms;pwd=kms"
adp = New OdbcDataAdapter("Select State_Id, State_Name from tab_states", con)
ds = New DataSet
adp.Fill(ds)

DListState.DataSource = ds.Tables(0)

DListState.DataTextField = "State_Name"
DListState.DataValueField = "State_Id"

DListState.DataBind()

con.Open()


Private Sub cmd_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Add.Click
Dim stateid As Integer
Dim Query As String

cmd.Connection = con

If txtCityName.Text = "" Then
MessageBox("Fied can not be null")
End If
If txtCityName.Text <> "" Then


'MessageBox(DListState.SelectedItem.ToString())
cmd.CommandText = "insert into tab_City(city_id,city_name,state_id)values(SEQ_cit y_ID.nextval,'" & txtCityName.Text & "','" & DListState.SelectedItem.Value & "' )"
cmd.CommandType = CommandType.Text

rd = cmd.ExecuteReader

MessageBox("New City has inserted")

End If
cmd.Cancel()
con.Close()
End Sub
Aug 10 '07 #1
1 990
kenobewan
4,871 Expert 4TB
Have you tried using the state name as the selected index and the id as the selected value?
Aug 10 '07 #2

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

Similar topics

2
by: Wm | last post by:
This is very peculiar -- for some reason, I'm getting 6-8 results from each of these queries, although only one listing matches. I have a pair of forms on one page: <FORM> Search for lastname:...
6
by: Wm | last post by:
I'm totally clueless on this one -- I'm getting 3 copies of every Email (in plain text, not HTML as expected), from a single mail() line... Can anyone tell me what might be causing the duplicates??...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
1
by: neeraj | last post by:
Hi people's I developed one MDI application with one MDI form and 2 child forms, form. Border style of first child forms set as Fixed3D and Window State set as normal (like dialog Box) and...
2
by: maxkumar | last post by:
Hi, I am running a ASP.NET 1.1 site on Win Server 2003 with IIS 6.0. The website has been running for about 1.5 years now. In the past, we used to have random cases of session variables getting...
0
by: Steve | last post by:
To begin, I'm using Adobe's Spry Framework for all my data in my XML page, it saves space and code on the HTML. Well, I want to make it so that certain cells are chosen and are either highlighted...
5
by: jediknight | last post by:
Is it possible to programmatically stop multiple browsers from getting the same session state? The problem I have is that whenever I open a new browse using File- I would like to stop this...
1
by: tricard | last post by:
Good afternoon all, I have recently been trying my hand out at the ADO model as before I have only used DAO (just thought I would expand my knowledge a bit). The problem I am having is that...
2
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in...
1
by: bhavanirayala | last post by:
Hi, I am sending the values from one method to another method to get the values from xml file based on the inputs. I am getting the error like:: Variable "$collType" will not stay shared...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.