|
cgai wrote: I wonder if you would be able to outline how you would design an implementation to my ComboBox scenario ?
I can't figure out what your ComboBox scenario is!!
Let's see... Are you saying that you have a ComboBox bound to a table that has a list of Names in it? The user picks a Name, then another ComboBox is supposed to fill with some other information, based on the Name picked??
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave Kreskowiak wrote: I can't figure out what your ComboBox scenario is!!
Let's see... Are you saying that you have a ComboBox bound to a table that has a list of Names in it? The user picks a Name, then another ComboBox is supposed to fill with some other information, based on the Name picked??
I'll try my best to outline the scenario:
I am updating a strContactName field (using a ComboBox cboName) in a tblCompany record. There is also a strCity field in the record which filters the list of possible names. There is a dt_tblContactNames DataTable in a dsLookups DataSet.
dt_tblContactNames Fill: "SELECT strContactName FROM tblContactNames WHERE strCity = (my city in this record)" (this is used for the ContactName dropdown list, and it works fine)
When the user clicks the Save button on the Form, the changes are written to the database via a stored procedure, for which I define and pass field values as parameters, in VB code. This technique works fine for all the other fields.
Some issues:
1. After the City and Name are entered, the Name needs to display in the ComboBox text whenever the record is retrieved. It seems like the dropdown list needs to be properly filled, otherwise the Name does not display.
2. I need to bind the cboName control to strContactName ... probably using .SelectedValue, but I don't see why .Text does not work as well ..
3. I need to know when to fill the dropdown list for the ComboBox. Yes, after the City changes, but also when the form is first displayed ...
I have set most of wiring in the Properties window for the ComboBox, but I Call the Fill for the dropdown, and the record Update, in VB code.
I hope that helps explain what I am trying to do ... probably a common scenario.
cgai: I am using VB.NET 2005 and WinForms. I have a bound (dropdownlist) ComboBox who's selection list is based on another field (City) on the Form. The Combo part is a 1-field query (strName) and I am storing the exact same strName field in the database. My selection list is working OK.
SteveH
|
|
|
|
|
Hello,
I want to refresh a form. The current finds sql servers on the network which it does. But sometimes it doesn't. I have put the function call in the form load, which calls the function to fill a list box of servers.
I have a button thats called refresh, which calls that function. However, even though it calls that function it does not work the same unless you close the form and open it again.
Is there some way to achieve something that refresh the form without closing and opening it again.
Many thanks in advance,
Steve
|
|
|
|
|
Move your code that finds the servers to a seperate method and have it return an array of strings. Create another method that clears and refills the ListBox. That method will be the one to call the method that retrieves the server list. Your code can then be called from anywhere in your form code.
Private Sub Form_Load(blah, blah) blah...
RefreshServerList()
End Sub
.
.
Private Sub Button1_Click(blah, blah) blah...
RefreshServerList()
End Sub
.
.
Private Function GetSqlServers() As String()
Dim Servers As String()
' Build your list of Sql Servers...
Return Servers
End Sub
.
.
Private Sub RefreshServerList()
Dim s As String() = GetSqlServers()
ListBox1.DataSource = s
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I'm having an XML file which is an extraction of a database request. I'd like to read in it with VB.Net like I can do when using direct database connection with command such as datareader for example.
Thx
Sybux
|
|
|
|
|
You can either load the XML file into a DataSet, which will treat it just like a DataSet returned from a database, or you can load it into an XmlDocument and use normal XML methods to manipulate it.
It sounds like all you want to do is iterate over a set of records so, to get your XML into a DataSet, all you have to do is:
Dim myData As New DataSet
myData.ReadXml(filepath)
There are various overloads of ReadXml, so use whatever is appropriate for your case.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thx for help but I still have got a problem.
Here is an extract of my xml file :
< ?xml version = '1.0'?>
< PAGE>
< DATA>
< DATA>
< seance i_seance="218765344" d_date="20060919" d_debut="13:30" d_fin="15:00" d_jour="mardi" n_semaine="38" type_seance="Enseignement">
< x_remarques>Groupe A non bilingue et B</x_remarques>
< ressource type="enseignant" libelle="MR X"/>
< ressource type="volee" libelle="Information documentaire, 2006-2007, S1"/>
< ressource type="matiere" code="7612F" libelle="Sociologie des organisations (Cours)"/>
< ressource type="classe" libelle="ID1B"/>
< ressource type="classe" libelle="ID1A Non bilingue"/>
< ressource type="espace" libelle="C101"/>
< /seance>
< seance i_seance="218766590" d_date="20060919" d_debut="15:15" d_fin="16:45" d_jour="mardi" n_semaine="38" type_seance="Enseignement">
< x_remarques>Groupes A non bilingue et B</x_remarques>
< ressource type="enseignant" libelle="MR A"/>
< ressource type="enseignant" libelle="MR B"/>
< ressource type="volee" libelle="Information documentaire, 2006-2007, S1"/>
< ressource type="matiere" code="7113F" libelle="Introduction � l'archivistique (Cours)"/>
< ressource type="classe" libelle="ID1B"/>
< ressource type="classe" libelle="ID1A Non bilingue"/>
< ressource type="espace" libelle="C101"/>
< /seance>
< /DATA>
< /DATA>
< /PAGE>
I've written the following code but doesn't not display it well :
Sub Main()
Dim myData As New DataSet
Dim mDataRow, mdr As DataRow
myData.ReadXml("test.xml")
For Each mDataRow In myData.Tables(1).Rows
System.Console.WriteLine("date : " & mDataRow("d_date"))
System.Console.WriteLine("Heure début : " & mDataRow("d_debut"))
System.Console.WriteLine("Heure fin : " & mDataRow("d_fin"))
System.Console.WriteLine("Jour : " & mDataRow("d_jour"))
System.Console.WriteLine("Type Séance : " & mDataRow("type_seance"))
For Each mdr In myData.Tables(2).Rows
System.Console.WriteLine(mdr(1) & " : " & mdr(2))
Next
Next
System.Console.ReadLine()
End Sub
Can some1 tell me where I'm wrong .
thx
|
|
|
|
|
VS2005 (vb) and SQL2005
ok im nearly beaten here... think its lack of sleep
I need a very very kind person to help me out as im totally losing the will to live
Ok i have an Default.aspx page with a textbox ( ID TXT1 ) and a Button. what i want to do, what ive been trying to do is when the button is clicked, it basicly does a a "Select count(*) from Table1.dbo.users where name = '" & TXT1.text & "'" and display the return value
ok to some its simple stuff but i have to start somewhere , so please can you explain it in laymans terms
thank you
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
Pete,
let's start slow...
1) are you able to establish a database connection from your webpage?
|
|
|
|
|
Hi,
Thanks for the reply. this is all new to me and im struggling like mad. Just for background, Im trying to create an Intra-net project... as a tester. I have my web.config file which has the connection string to the SQL server, and im presuming that if the connection string was incorrect there would be an error. as below
The only conponents i have added are the textbox and Button
section of web.config
<connectionstrings>
<remove name="LocalSqlServer">
<add name="LocalSqlServer"
="" connectionstring="Data Source=DevSQL2;Initial Catalog=TestDataBase;Integrated Security=True" providername="System.Data.SqlClient">
thanks
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
grrr sorry this is what was meant to be added
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer"
connectionString="Data Source=DevSQL2;Initial Catalog=TestDataBase;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
nlarson11
I got an email from the site, but no message on the forum . From the email tho yes i know the connection string is correct.
If its easier you can mail me direct ?
I really do need help..... all this computer stuff is way over my head !!
|
|
|
|
|
look at your webpage.
double click on the button
that will add code for the click event of your button
inside the click event-connect to the database.
run your select statement returning a dataset(ds) using either a helper or an adapter
textbox1.text = ds.tables(0).rows(0)(0)
-- modified at 10:58 Tuesday 24th October, 2006
|
|
|
|
|
This may be simple but I need to display a status message in a label while creating a zip folder. For example, while the folder is being created I want the label to display please wait and when the folder is done I want the label to display finish.
jds1207
|
|
|
|
|
label1.text = "Please Wait..."
'the line below is necessary because the zip is an intesive operation and the label1 may never display the text(or paint itself)
application.doevents
call zipfile()
label1.text=string.empty 'or visible=false
helpful or more to it?
|
|
|
|
|
I am a little confused. Here is the code where I call the functions under the button click:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
When CreateBackupFolder & CreateZip are in progress I want the label to display please wait and when done I want the label to display finish.
I hope I explained this clear enough for you.
jds1207
|
|
|
|
|
So, change your label before you call your Create.... thingy's.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
StatusLabel.Text = "Please wait..."
Application.DoEvents()
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
.
.
.
It would be better if you made a method to change the status label so you can call it from anywhere in your form code though...
Private Sub UpdateStatusUI(ByVal message As String)
StatusLabel.Text = message
Application.DoEvents()
End Sub
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thank you! This worked fine.
|
|
|
|
|
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dirname As String = DateTime.Now.ToString("MM_dd_yyyy_hh_mm_ss") & "\"
label1.text = "Please Wait..." '<<<<<<<<<<<<
Application.doevents '<<<<<<<<<<<<
CreateBackUpFolder(GlobalVariables.backupfolder, dirname)
CreateZip(GlobalVariables.sourcefolder, GlobalVariables.backupfolder & dirname & GlobalVariables.backupfile)
label1.text = "Finished" '<<<<<<<<<<<<
End Sub
|
|
|
|
|
Thank you also! Your code is pretty much the same.
|
|
|
|
|
Hi,
Can we use a vb6 file vb.net project. If yes then how it can be done.
Please help me.
Thanks & Regards
Mishra
|
|
|
|
|
There are many different types of files - which one do you mean? Source? Compiled dll? What?
|
|
|
|
|
Although there a lot of similarities between VB6 and VB.NET, VB6 code usually has to be re-written to work properly in VB.NET. For instance, a Long value in VB6 is 32-bit integer whereas it's a 64-bit integer in VB.NET. The equivilent data type to a VB6 Long would be an Integer in VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
anyone know about this error message?
System.InvalidCastException:Cast from type 'DBNull'to type 'Date'is not valid
at Microsoft.VisualBasic.CompilerServices.DateType.FromObject(Object Value)
may i know the way to solve it.....
|
|
|
|
|
You're trying to convert a Null value into data type Date which is not allowed. Post your code and either I or someone else will show you where you went wrong & how to fix it.
|
|
|
|