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

to get 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

Expand|Select|Wrap|Line Numbers
  1. Dim ds As New DataSet
  2.        Dim stateid As New Integer
  3.        con.ConnectionString = "Driver={Microsoft ODBC for Oracle};server=dbserver;uid=kms;pwd=kms"
  4.        adp = New OdbcDataAdapter("Select State_Id, State_Name from tab_states", con)
  5.        ds = New DataSet
  6.        adp.Fill(ds)
  7.  
  8.        DListState.DataSource = ds.Tables(0)
  9.  
  10.        DListState.DataTextField = "State_Name"
  11.        DListState.DataValueField = "State_Id"
  12.  
  13.        DListState.DataBind()
  14.  
  15.        con.Open()
  16.  
  17.  
  18. Private Sub cmd_Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_Add.Click
  19.        Dim stateid As Integer
  20.        Dim Query As String
  21.  
  22.        cmd.Connection = con
  23.  
  24.        If txtCityName.Text = "" Then
  25.            MessageBox("Fied can not be null")
  26.        End If
  27.        If txtCityName.Text <> "" Then
  28.  
  29.  
  30.            'MessageBox(DListState.SelectedItem.ToString())
  31.            cmd.CommandText = "insert into tab_City(city_id,city_name,state_id)values(SEQ_city_ID.nextval,'" & txtCityName.Text & "','" & DListState.SelectedItem.Value & "' )"
  32.            cmd.CommandType = CommandType.Text
  33.  
  34.            rd = cmd.ExecuteReader
  35.  
  36.            MessageBox("New City has inserted")
  37.  
  38.        End If
  39.        cmd.Cancel()
  40.        con.Close()
  41.    End Sub

can u please send a javascript to get the state_id
Aug 10 '07 #1
0 969

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

Similar topics

32
by: Xah Lee | last post by:
is it possible to write python code without any indentation? Xah xah@xahlee.org http://xahlee.org/PageTwo_dir/more.html
4
by: Chad Crowder | last post by:
I've taken a look at this article http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.asp which someone posted a month or so ago regarding setting up SQL...
1
by: Johan Nedin | last post by:
Hello! I have a problem with SQLSession state on my ASP.NET pages. SQLSession state behaves very different from InProcess session state, which I think is very bad. I can understand some of...
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
1
by: Neo | last post by:
hi, This is my first post in C++ group, so please be nice to me. Thanks. Also, I will post my first C++ program following. There is a compile error, I cannot figure it out even I can fix it. And...
4
by: Shawnk | last post by:
This post is intended to verify that true value semantics DO NOT EXIST for the Enum class (relative to boolean operations). If this is true then (thus and therefore) you can not design state...
4
weaknessforcats
by: weaknessforcats | last post by:
Design Patterns State Often computer software operates based on a condition called a state. These states traditionally have been implemented using a switch statement. The cases of the switch...
11
by: tuom.larsen | last post by:
Dear list, I'm writing very simple state machine library, like this: _state = None def set_state(state): global _state _state = state
4
by: laktofil | last post by:
This may seem like an abstract question on behavioral inheritance. Anyway, I'm building a hierarchical state machine in C++ (with gcc for target platform Gentoo Linux). More precisely, I'm using this...
1
by: W Karas | last post by:
Virtual functions could have multiple definitions, for different object states. The prototype of a virtual member function could have an optional reserve word "for" followed by a comma-separated...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.