Subscribe to Subscribers

Forums » .NET » Visual Studio »

This code is not working properly


Posted Date: 10 Aug 2012      Posted By:: Nirav Lalan     Member Level: Silver    Member Rank: 1673     Points: 5   Responses: 3



this code does not show integer number's data into textbox. not working properly.

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

If ComboBox1.SelectedIndex Then
con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\softwares\Rental\Rental\Rental.mdf;Integrated Security=True;User Instance=True"
con.Open()
Dim str As String = "select * from Payment where Order_No='" & ComboBox1.Text & "'"
Dim cmd As SqlCommand = New SqlCommand(str, con)
Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)
Dim ds As DataSet = New DataSet()
da.Fill(ds)
Dim i As Integer
cmd.ExecuteNonQuery()
For i = 0 To ds.Tables(0).Rows.Count - 1
Order_NoTextBox.Text = ds.Tables(0).Rows(0)(0)
Client_NameTextBox.Text = ds.Tables(0).Rows(0)(1)
Contact_PersonTextBox.Text = ds.Tables(0).Rows(0)(2)
PeriodTextBox.Text = ds.Tables(0).Rows(0)(3)
Total_AmountTextBox.Text = ds.Tables(0).Rows(0)(4)
Bill_NoTextBox.Text = ds.Tables(0).Rows(0)(5)
Bill_DateDateTimePicker.Text = ds.Tables(0).Rows(0)(6)
Bill_AmountTextBox.Text = ds.Tables(0).Rows(0)(7)
PaymentTextBox.Text = ds.Tables(0).Rows(0)(8)
StatusTextBox.Text = ds.Tables(0).Rows(0)(9)
Next
con.Close()
End If
End Sub




Responses

#683930    Author: Prasad kulkarni        Member Level: Diamond      Member Rank: 8     Date: 10/Aug/2012   Rating: 2 out of 52 out of 5     Points: 1

What error it gives ?
what output you want exactly ?

Thanks
Koolprasd2003
[DotNetSpider MVM]


 
#683994    Author: Kapil      Member Level: Gold      Member Rank: 50     Date: 12/Aug/2012   Rating: 2 out of 52 out of 5     Points: 3

Hi,

You have not elaborated what exactly is not working, you should so we can provide the solution for that. But anyways, looking into your code i have some question,

What is your Query returning? Does it return more then one row if yes How you can display all rows in Text Box's or some controls as you are trying to do in for loop.

Your for loop is going to iterate and display only one row in your controls.

If that is not working let us know, if you are just displaying the data here and your query is returning more then one row you should use data controls like DataGrid, Gridview, Repeater and so on based on your requirement.

Hope that will help and let us know what is not working..

Happy Coding

"Please don't forget to Rate this answer if you found it usefull"

http://www.dotnetspider.com/mentors/86-kapil-deo.aspx
My Blog


 
#684192    Author: Nirav Lalan      Member Level: Silver      Member Rank: 1673     Date: 13/Aug/2012   Rating: 2 out of 52 out of 5     Points: 1

thnx 2 all.. now it's working properly..




 
Post Reply
You must Sign In to post a response.

Next : Create dynamic textbox on tree view node creation
Previous : Update a access database with sql
Return to Discussion Forum
Post New Message
Category:

Related Messages

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Talk to Webmaster Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2013 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.