|
I have a form that uses a comboboxes selected index value to populate textboxes, but when I try to edit the information, it doesn't save the information back to the database. Any ideas or suggestions would be appreciated?
|
|
|
|
|
Your going to have to supply much more information about your problem and what and how your doing things. So far, it looks like you have combo boxes bound to text boxes, but nothing about how your getting your data from the database, what code you have writing data back to the database, what version of VB your using, just to name a few things. Code samples of these things would help us out greatly!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
On load of form, The combobox is filled with the information(Ex. Fullname), which is done by a dataset. Then based on its selected index value there are textboxes that are data-bound based on that(Ex. Firstname, lastname,address). This is done by another query which the select statement is like this:
Select * from TCust Where (Fullname=?)
After the textboxes are populated with the correct data, Then you can select the Edit button which allows you to actually change the information, but when you go to save the changes whether it be by the same dataset that populated the textboxes or by a declared dataset that gets the changes from the dataset that filled the textboxes, It won't save the changes and update the table. I've tried just about everything I can think of, and everything I come up with takes a lot of steps and I'm thinking that there has to be an easier way of doing this. I hope this helps you.
|
|
|
|
|
ccotton333 wrote:
Select * from TCust Where (Fullname=?)
Are you editing the Fullname? If so, your aparently invalidating your Primary Key which is what is being used to uniquely identify the record your editing. If you modify this key, your UPDATE SQL statements won't work because you're trying to update a record that doesn't exist, as specified by your new primary key.
Like I said, without seeing the code your using, it's nearly impossible to tell you what's going wrong.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Well the code is kind of long:
Public Class frmMain4
Inherits System.Windows.Forms.Form
Private Sub cboFullname_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboFullname.SelectedIndexChanged
Dscustinfo21.Clear()
dbCustInfo.SelectCommand.Parameters("fullname").Value = cboFullname.Text
dbCustInfo.Fill(Dscustinfo21)
End Sub
Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEdit.Click
'allows you to edit a record
If btnEdit.Text = "Edit" Then
UnlockTextBoxes()
btnSave.Enabled = True
btnEdit.Text = "Cancel"
ElseIf btnEdit.Text = "Cancel" Then
LockTextBoxes()
btnSave.Enabled = False
End If
End Sub
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'saves the record
LockTextBoxes()
btnSave.Enabled = False
btnEdit.Text = "Edit"
Try
dbCustInfo.Update(Dscustinfo21, "tcust")
Catch ex As Exception
MsgBox("Update didn't work.")
End Try
MsgBox("Update must have worked.")
End Sub
Private Sub mnuFileExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileExit.Click
'closes the program
Me.Close()
End Sub
Private Sub UnlockTextBoxes()
txtLastName.ReadOnly = False
txtName.ReadOnly = False
txtAddress.ReadOnly = False
txtAddress1.ReadOnly = False
txtCity.ReadOnly = False
txtState.ReadOnly = False
txtZip.ReadOnly = False
txtCountry.ReadOnly = False
txtHomePhone.ReadOnly = False
txtWorkPhone.ReadOnly = False
txtMobile.ReadOnly = False
txtPager.ReadOnly = False
txtEmail.ReadOnly = False
End Sub
Private Sub LockTextBoxes()
txtLastName.ReadOnly = True
txtName.ReadOnly = True
txtAddress.ReadOnly = True
txtAddress1.ReadOnly = True
txtCity.ReadOnly = True
txtState.ReadOnly = True
txtZip.ReadOnly = True
txtCountry.ReadOnly = True
txtHomePhone.ReadOnly = True
txtWorkPhone.ReadOnly = True
txtMobile.ReadOnly = True
txtPager.ReadOnly = True
txtEmail.ReadOnly = True
End Sub
Private Sub frmMain4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
dbFullname.Fill(Dsfullname21)
btnSave.Enabled = False
End Sub
End Class
|
|
|
|
|
HI guys its me again I'm really stuck and I need the help. I want to create an instance of the line control on my form at run time. But some how the following code doesn't work
DIm line1 as Line
Set line1 = New Line
'setting line properties
line1.visible = true
I really need to knwo how to do this and I don't want to use any drawline functions as I don't want to draw a bitmap just want to be able to create an instance of the line control.
I really need the help
I'm using vb6
|
|
|
|
|
You probably didn't add the new Line control to the Controls collection of the object onto which your drawing. For instance, if your drawing on the surface of a Form (not a picture box!), you would have to add the control to the Controls collection of the Form:
Dim WithEvents myLine As Line
Set myLine = Form1.Controls.Add("VB.Line", "myLineControl")
myLine.Visible = True
The VB.Line might be a bit different. Check in the Object Browser (F2) to see what the exact name of the control is if not VB.Line .
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Does anyone know of any examples of how to write each of these into code? When I built my dataset using the Visual Basic wizard, it was unable to create the update and delete commands. It said "Could not determine which columns uniquely identify the rows for "Address". I'm sure there are ways to programatically do these commands. Thanks in advance.
Beginner in ASP.Net and VB.Net
|
|
|
|
|
It couldn't do that because your table that holds the "Address" field doesn't have a primary key defined in it. You need a column that will uniqely identify each record in the table. See this[^] little page for a description of Primary Keys.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks dave;)
Beginner in ASP.Net and VB.Net
|
|
|
|
|
This seems to be very simple, But... (new to vb.net)
I have a form with a tabcontrol with 2 pages. One page has a grid with sales entries. The other page has textboxes on it with the values form the table. I have a recalc button that calculates the salesman commission. It works great until I manually change the commission percentage in the textbox or any other textbox value. The calculation works ok, but the commission textbox does not show the new calculated value. If I click on the other tab and then click back to the detail page the value appears. If I change the commission percentage value through the use of a button it works fine! This must be something really basic I'm doing wrong. Do I need to valiadte and manually write text back to commission box? Help Please!
' dataset = dsSalesFile
' table = SalesFile
' After data is selected I bind as follows:
txtSalesTotal.DataBindings.Clear()
txtSalesTotal.DataBindings.Add("Text", dsSalesFile, "SalesFile.SalesTotal")
txtCommPcnt.DataBindings.Clear()
txtCommPcnt.DataBindings.Add("Text", dsSalesFile, "SalesFile.CommPcnt")
txtCommission.DataBindings.Clear()
txtCommission.DataBindings.Add("Text", dsSalesFile, "SalesFile.txtCommission")
'Subroutine to recalc
Dim CurPosition As Integer
CurPosition = BindingContext(dsSalesFile, "SalesFile").Position
Dim WorkRow As DataRow = dsSalesFile.tables("SalesFile").Rows(CurPosition)
WorkRow ("Commission") = Math.Round(CDec(WorkRow("CommPcnt")) / 100 * CDec(WorkRow("SalesTotal")),2)
|
|
|
|
|
Hello,
I created a small program to show some data in a datagrid. There are about 100 records but the datagrid has no scrollbars so you can't see all te records.
What can i do?
I fill the datagrid up like this:
Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\films.mdb"<br />
OleDbConnection1 = New OleDbConnection(connStr)<br />
OleDbConnection1.Open()<br />
myDs = New DataSet<br />
sqlStr = "SELECT * FROM films"<br />
OleDbDataAdapter1 = New OleDbDataAdapter(sqlStr, OleDbConnection1)<br />
OleDbDataAdapter1.SelectCommand.CommandText = sqlStr<br />
oleDbCommandBuilder1 = New OleDbCommandBuilder(OleDbDataAdapter1)<br />
OleDbDataAdapter1.Fill(myDs, "dtFilms")<br />
currentRow = 0<br />
<br />
Dim tableStyle As DataGridTableStyle<br />
tableStyle = New DataGridTableStyle<br />
tableStyle.MappingName = "dtFilms"<br />
dtgFilms.TableStyles.Clear()<br />
dtgFilms.TableStyles.Add(tableStyle)<br />
dtgFilms.DataSource = myDs.Tables("dtFilms")
Thanks in advance!
|
|
|
|
|
VB6 COM component uses .NET libraries. One .NET library tries to
locate folder in the app's directory with its data. There are
two clients of vb6 component: vbscript and vb6 late binding,
both are essential.
If the VB6 built as ActiveX.EXE, .NET library fails to locate
its folder (with both clients of ActiveX), if built as ActiveX.DLL,
library fails only with VB6 late-binding client, with VBScript all
goes Ok. .NET clients of the same .NET library have no problems
with it; users have necessary permissions...
I'm going slightly mad...
|
|
|
|
|
Your component is assuming that it's data directory wil be a sub-directory of the current directory. This is bad practice because you can't guarantee that the current directory is the one that the app is launched from. Try to code your component to get the applications path first, then parse it up and add the subdirectory to that path. This should point you to the correct directory every time, instead of making assumptions about what directory your running in. you'll have much better luck if you specify a complete path to your files instead of a partial path.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Can anyone help me. I have a function that will let you select any of the drives on the system but all i want is to be able to select the cd-rom/dvd-rom drives.
|
|
|
|
|
|
Hello frnds,
there is a problem here, I have a datagrid when i add a new record to the grid and press save button it saves, After saving if i refresh the page the record is saving again - i mean a duplicate record is getting saved in the daatbase after refresh. Can any body help me in this regard
thanx in advance
irsh
|
|
|
|
|
You'll have better results if you post your question in the ASP.NET Forum. Also, I'll tell you that it very much depends on how your code is written wheather or not this will be an easy fix. Post you question and database/datagrid handling code in the ASP.NET Forum for better results to your problem.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
I know a little about multi-threading in vb.net
I know that we can execute a procedure on a new thread by using:
<br />
Dim t as New Thread(AddressOf proc)
"proc" should be of the form :
<br />
Sub proc()<br />
'code...<br />
End Sub<br />
Can i make proc a sub with arguments?
like this:
<br />
Sub proc(str as String)<br />
'code...<br />
End Sub<br />
and call proc on a new thread and specify str?
I mean something like:
Dim t as New Thread(AddressOf proc("hello"))
If yes, how?
|
|
|
|
|
Sub that starts a thread can't have arguments.
You should set some kind of property or field before start the thread and use it inside.
|
|
|
|
|
ThreadStart's can't have arguments. Normally, you would put this code into a class, along with some public fields that would represent the parameters for this method you want to start. Then you create and instance of the class, set the fields to the values you need, create your ThreadStart object and point it at the method in your instantiated class, then run it. The method would have to pick up its parameters from the public fields you set in its class.
Public Class MyThreadClass
Public argument1 As Integer
Public Sub MyMethod()
Dim whatever As Integer = argument1
.
. your method code...
.
End Sub
End Class
' Code in your calling class.
Dim mtc As New MyThreadedClass
mtc.argument1 = 30
Dim t As New Thread( AddressOf mtc.MyMethod )
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You could use a delegate then invoke it asynchronously. Delegates can take arguments unlike threads.
|
|
|
|
|
Can you please give me a short example? What is a delegate?
I would apreciate your help.
Thanks in advance
|
|
|
|
|
guys,
im developing a ping plotting app, which will run on a centrallised server & ping a particular URL continuously for checking its availability. now i want to create a browser based I/F for that exe app to view reports & add some remarks against a particular entry. so, the admin shud be able to access it from anywhere for the above ops. please suggest how i cud do that?
DaHacker Loves Hackin!
|
|
|
|
|
This would just be ASP.NET Web project. Nothing special there. You'll need to have IIS or the Personal Web Server running on your machine that'll be serving up the web pages and doing the pinging.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|