Jump to content
Xtreme .Net Talk

Smithbr

Members
  • Posts

    16
  • Joined

  • Last visited

Smithbr's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. I have question about if something is possible. I want to bind a combobox to my database. The problem is that the table I want to bind to have composite primary key made up of three entity sets. Is there a way that I can get a combo box to show all three columns of data as opposed to just one column like I have always seen. Any suggestions or a notice that it is not possible would be great. Thanks
  2. Hello all, I just finished this VB.net program I was working on and started testing it when I noticed a huge hole in it that some how I missed from the beginning. I have a datagrid that is filled based on a access DB. The columns that are in the datagrid include: lineseqno, itemnumber, quantity, unit price, and discount %. I also have a column that is created at run time called Total that is quantity * unit price. Now to my question: How can I either get the total column to update to the database even though it is not part of the data adapter. (I created the DA and DS at design time) If that will not work, how can I get the unit price to change based on if a radio box is selected (if a discount was taken, make unit price = unit price*(1-Discount%) ). I am not sure how to do this either way..and both I think will fit my purpose. Any suggestions? Thanks.
  3. I was wondering how I can find the total of a column in a datagrid and display it in a label. Any suggestions? Thanks
  4. do you have a data adapter created, either do it at design time or programmatically. Either way, you need to create a data adapter, then from that generate a dataset. Bind the dataset to the datagrid. Try this: dim mydataset as new dataset oledbdataadpater1.fill(mydataset) datagrid.setdatabinding(mydataset, "MyTable") Hope this helps.
  5. Thank you so much...I have been trying to figure this out for way longer than I wan to admitt....also, for anyone in the future, The code is actually slighty differnet then above if it is going to work. It is: If dr.Item("Paid") Is System.DBNull.Value Then Thanks again Nerseus!
  6. is there another way to tell teh program to only add the date to the blank field in the column other than --> dr.Item("Paid") = "" I am pretty sure that this is where my problem is...how else can I write null fields ...
  7. Hello, I am having a real problem figuring out why this code is not working in my vb.net project. I am tryig to get today's date, which is dispalyed in lbltdatedisp to insert into the paid column only if teh field is blank...in other words, i want to be able to update it and mark the date on day...go through and add a few more records, and mark those with a different date withut changing the date of those mark previously. In my access database the paid column is set as text so I did not think it whoud be a problem comparing it via ="" ( as you will see below in my code). Can anyone help me out with this... really need to have this working by the end of the day and can not see what I need to do...Thanks in advance for everything. Code: -------------------------------------------------------------------------------- Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click If DsInvoice1.HasChanges Then If MessageBox.Show("You are about to save all changes made in the Datagrid, Continue?", "InvoiceHistory", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then 'Da.Update(detail, "InvoiceHistory") Try Dim dr As DataRow For Each dr In DsInvoice1.Tables(0).Rows If dr.Item("Paid") = "" Then dr.Item("Paid") = lbltdatedisp.Text End If Next OleDbDataAdapter1.Update(DsInvoice1) grdComm.Refresh() Catch Ex As OleDbException System.Diagnostics.Debug.Write(Ex.Message) End Try End If End If End Sub -------------------------------------------------------------------------------- the error message i keep getting is An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll Additional information: Operator is not valid for type 'DBNull' and string "". and it is referencing the line : Code: -------------------------------------------------------------------------------- If dr.Item("Paid") = "" Then --------------------------------------------------------------------------------
  8. Hello, I am having a real problem figuring out why this code is not working in my vb.net project. I am tryig to get today's date, which is dispalyed in lbltdatedisp to insert into the paid column only if teh field is blank...in other words, i want to be able to update it and mark the date on day...go through and add a few more records, and mark those with a different date withut changing the date of those mark previously. In my access database the paid column is set as text so I did not think it whoud be a problem comparing it via ="" ( as you will see below in my code). Can anyone help me out with this... really need to have this working by the end of the day and can not see what I need to do...Thanks in advance for everything. Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click If DsInvoice1.HasChanges Then If MessageBox.Show("You are about to save all changes made in the Datagrid, Continue?", "InvoiceHistory", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) = DialogResult.OK Then 'Da.Update(detail, "InvoiceHistory") Try Dim dr As DataRow For Each dr In DsInvoice1.Tables(0).Rows If dr.Item("Paid") = "" Then dr.Item("Paid") = lbltdatedisp.Text End If Next OleDbDataAdapter1.Update(DsInvoice1) grdComm.Refresh() Catch Ex As OleDbException System.Diagnostics.Debug.Write(Ex.Message) End Try End If End If End Sub the error message i keep getting is An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll Additional information: Operator is not valid for type 'DBNull' and string "". and it is referencing the line : If dr.Item("Paid") = "" Then
  9. I have a couple of questions about a project I am working on involving an access database and a vb.net windows form. I have an Access Database that is used to keep track of brokers commissions. On a form, I display the line items from a particular invoice (based on the invoice number typed into the textbox) in a datagrid. Since I'm pretty new to VB Net, I would like to find out if it is possible to add new tasks, change existing tasks, or delete existing tasks using just the datagrid. It looks like I can type in the datagrid, to add a new task. It also looks like I can change existing tasks information, but I don't know how to identify the changes so I can update the database. For adds - I have 4 textboxes and two comboboxes that I want to use to add new records. How do I get the textboxes and comboboxes to add to the datagrid, so it can be inserted into the database? For updates or deletes, how can I identify which line on the datagrid I have updated or marked to be deleted? After I have updated the data grid, how do I take all the data in the datagrid and send it to a new table in the same access database(not the same table is was populated with)? Also, I have two radio buttons above the datagrid that is check yes or no depending on if teh customer took the discount. If the yes radio button is checked I want to total amount for each line item to be lowered by a % that is displayed in a label. (I could also have the discount percent be displayed in the datagrid but don't know how to make the datagrid know that if the radio button "YES" is selected to use the amount in in the discount column in the total calculation. Thanks, Brent
  10. That was what I thought would be the easiest way but because Table1 contains the details for Table2 it can not sum (what I need done)...it would just return the contents of Table1. I can only get teh data from Table2 if it comes from its own table...I checked ways to query in Access and foudn that I must use 2 tables...Do you know how I could set it up with two tables? Brent
  11. Hello, I am having a problem viewing data in a form from more than one table. I have read through a bunch of tutorials and MSDN files and whatnot but have not been able to nail down what i need to do. Here is the code I have so far....it worked when I only needed to data from one table but now that I have introduced the second I have run into tons of problems. I am not sure if I need two DataAdapters and one DataSet or two DA's and two DS's. Does anyone see what I need to do with my code to get this to work? Private Sub cmdfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfind.Click 'write the query to get the data you want Dim strhistory As String = "Select Invoicenumber, InvoiceDate, Total, CustomerNumber, BrokerID, LineSEQNo, ProductLine, COMM, Terms, Description, DiscountPercentage FROM PendingCommissions WHERE InvoiceNumber = " & txtinvnum.Text & " ORDER BY BrokerID, ProductLine DESC" Dim strinvtotal As String = "SELECT InvoiceNumber, SUM(Total) AS InvTotal FROM InvoiceHistory WHERE InvoiceNumber = " & txtinvnum.Text & " GROUP BY InvoiceNumber" 'Set up the data adapter and pass to it the sql statement and the connection Dim daHistory As OleDbDataAdapter = New OleDbDataAdapter(strhistory, OleDbConnection1) Dim dainvtotal As OleDbDataAdapter = New OleDbDataAdapter(strinvtotal, OleDbConnection1) 'set the data set and fill it with data Dim History As DataSet = New DataSet daHistory.Fill(History, "PendingCommissions") dainvtotal.Fill(History, "InvoiceHistory") 'set the datatable Dim dtH As DataTable = History.Tables("PendingCommissions") Dim dtIT As DataTable = History.Tables("InvoiceHistory") 'Finds the number of rows in a record and declares it Dim rowtotal As Integer rowtotal = dtH.Rows.Count Dim First As Integer Dim Last As Integer First = 0 Last = rowtotal - 1 I tried here to use 2 da's and 1 ds...it did not work but maybe I have it set up wrong. When I run it the error always comes at dainvtotal.Fill(History, "InvoiceHistory") Brent
  12. I am trying to use a datagrid for the first time to display and eventually update and add data from a msAccess database. Here is the code I have so far and at the bottom I have the error message I am getting. If anyone knows why I am getting this based on the code, I could really use the help. I am still new to Vb.Net. Public Class frminvoice Inherits System.Windows.Forms.Form Dim CmdInvoice As New OleDb.OleDbCommand Dim dacomm As New OleDb.OleDbDataAdapter Dim dscomm As New DataSet Private Sub frminvoice_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load DbConnect.Open() dacomm.SelectCommand = CmdInvoice End Sub Private Sub cmdfind_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdfind.Click With CmdInvoice .Connection = DbConnect .CommandType = CommandType.Text .CommandText = "SELECT InvoiceDate, InvoiceNumber, CustomerNumber, BrokerID, LineSEQNo, ItemNumber, ProductLine, QuantityShipped, LastUnitPrice, Total, COMM, Commissions, Terms, DiscountPercentage FROM Pending Commissions WHERE InvoiceNumber = " & txtinvnum.Text End With dscomm.Clear() dacomm.Fill(dscomm) dbgcomm.DataSource = dscomm.Tables(0) End Sub When I go to run it, I get the error: "An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in system.data.dll " referring to the code "Dacomm.fill(dscomm)" located under the find button. I get this error when I type in the invoice number adn then click FIND. Any ideas on what is going on or what I need to change? Thanks, Brent
  13. I have just finsihed creating an access database that analyzes sales data and finds commissions and whatnot. I am trying to now use VB.Net to finish the second part of the project. What I want to do is have the user type in the invoice number into a textbox and click a command button, this will return the line detail from the invoice as well as the broker, invoice total, customer, etc. Each invoive have a different number of line items so I am not sure if or how to set it up so that it would display the records in labels and textboxes. I not sure how to display multiple records in VB, let alone a varying amount of records. I have only used VB adodc in VB 6.0 and to display one record at a time. Is there any way that I can do this. Any way that I can display the results of the query in the form. I am pretty new to VB.Net so any suggestions on where to start would be greatly appreciated.
  14. I am creating an app that will allow the user to type in the invoice number and it will retrieve all relevant data associated witht the invoice number. Now the invoice info is from an accountng program that is linked to access. I can not change the properties of hte access table because it is linked. The problem is that the invoice number in access it set up as a text field. I want it so the user does not have to type quotes around the invoice number when they use the app. The code I tried before is: Dim strsql As String = "SELECT InvoiceNumber, Division, CustomerNumber, SalespersonCode, NonTaxableAmount FROM AR4_OpenInvoice WHERE InvoiceNumber = ' " & txtinvnum.Text & " ' " This woudl not work for some reason...I thought that this was the right way. Any suggestions would be great. Thanks
  15. I am trying to set up a VB.net program that will allow the user to enter an invoice number into a textbox, then click a retrieve command button, from this I want to populate 4 labels with the corresponding data relevant to the invoice number. I have the database linked using the OleDbConnection, OleDbDataAdapter, and DsIvoice. I have only programed in VB 6.0 but now I am using VB.Net so I am kinda lost as to all the new ways of doing things. Does anyone know what code I will need to put behind the Retrieve command button including how to define the variables. Later, I want this data to be carried over so that I can use a Select Case procedure to determine a commission rate based on the Salesrep, product, and vendor (all things I want to get pulled up when you retrieve the data associated witht he invoice number). Any help would be great..I just don't even know where to start. Thanks
×
×
  • Create New...