|
Is this for a Windows Form? If so .NET 2.0 brought back the masked text box which can only allow numerics if you set that property but you can also just validate the text after the fact.
A better way to do this on your own would be to use the textbox's KeyPress event or something along those lines and look at the following.
If e.KeyChar = Chr(CharCode for 0-9) Then
e.Handled = True
Else
e.Handled = False
End If I think that is all you really need to do.
-- modified at 12:10 Tuesday 29th May, 2007
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
how to work with datagrid using
1)delete command( permanently to remove all selected rows or selected single rows)
in sql database through datagrid during run time in vb.net windows application
and
2)update and save the changed values permanently in sql database through datagrid during run time in vb.net windows application?
|
|
|
|
|
If you bind this to a dataset object and provide the delete/update/insert commands then it is all taken care of for you. All you have to do is at some point call the tableAdapterName.Update(dataSetName.dataTableName) .
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.TblUserTableAdapter.Fill(Me.DatabaseDataSet.TblUser)
End Sub
Private Sub TblUserBindingNavigatorSaveItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TblUserBindingNavigatorSaveItem.Click
Me.Validate()
Me.TblUserBindingSource.EndEdit()
Me.TblUserTableAdapter.Update(Me.DatabaseDataSet.TblUser)
End Sub
It doesn't save information into my database. Help!
|
|
|
|
|
how to work with datagrid using
1)delete command( permanently to remove all selected rows or selected single rows)
in sql database through datagrid during run time in vb.net windows application
and
2)update and save the changed values permanently in sql database through datagrid during run time in vb.net windows application?
|
|
|
|
|
Hello all, I creating a Temp DataSet and Adapter, populating it and then doing an Insert to move data from this table back into the orginial table I copied it from but with a new DATE. I have it all working fine so far but when I get to trying to list the value of one of my columns (the most inportant one) I can't seem to grab the value. Below is what I have as of now. The line that I am having a problem with is OrderName = ADS.Orders.Select.ToString but I wanted to show you exactly what I am doing. Does anyone have any suggestions? Thank you for any help that you can provide...
Dim NewVisitDate As String
Dim PriorVisitDate As String
Dim SQL As String = String.Empty
'set Variables
NewVisitDate = txtVisitDate.Text
PriorVisitDate = Me.cbobxPriorDates.Text.ToString
MR = frmQuestionnaire.txtMRNo.Text
'create SQL to filter out data
SQL = "SELECT OrderMR, OrderDate,Order FROM (Orders) WHERE (OrderMR='" & MR & "') and (OrderDate= #" & PriorVisitDate & "#)"
'create new DataSet and new DataAdapter
Dim dr As OleDbDataReader
Dim ADS As New AnesDataSet
Dim CopyOrders As New OleDbDataAdapter(SQL, Connection)
CopyOrders.Fill(ADS, "Orders")
'CopyOrders.Fill(ADS.Orders)
Try
Connection.Open()
Dim Command As New OleDbCommand(SQL, Connection)
dr = Command.ExecuteReader()
Catch ex As Exception
End Try
'run a ForEach statement to modify all of the records in the ADS.Orders table
Dim Row As DataRow
Dim OrderName As String
Dim SQLInsert As String = String.Empty
For Each Row In ADS.Orders.Rows
OrderName = ADS.Orders.Select.ToString
'setup an SQL to change the Date and Insert new records
SQLInsert = "INSERT INTO Orders (OrderMR, OrderDate, [Order]) VALUES (@MR, @NewVisitDate,@OrderName)"
Dim Command_Insert As New OleDbCommand(SQLInsert, Connection)
Command_Insert.Parameters.AddWithValue("@orderMR", MR)
Command_Insert.Parameters.AddWithValue("@OrderDate", NewVisitDate)
Command_Insert.Parameters.AddWithValue("@Order", OrderName)
Command_Insert.ExecuteNonQuery()
'Console.Write(Command_Insert)
|
|
|
|
|
Are you attempting to update the date or just add back in all the rows with a new date in addition to the originals?
Also, what is the command that is executed at the line OrderName = ADS.Orders.Select.ToString ?
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
Hey Cleako, thanks for your response.
I am writing back the records with a new date in addition to the originals.
That line that you noticed is where my problem is. I can't figure out what to set my OrderName variable to. I can't find anything from the intellisense list that will give me the feild value of Orders on the row that I am on.
|
|
|
|
|
If you dont have a strongly typed DataSet where the columns are provided then you will need to access the column this way.
For Each Row In ADS.Orders.Rows
OrderName = row("Order").ToString I hope that helps!
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
That is EXACTLY what I needed. Thanks CleaKO!!
|
|
|
|
|
We are building a html(some controls) and assigning to a div's innerhtml.
They are built using some validations. The size of the string in any case would be around 200 KB(The controls are more). We are calling one or two functions in a loop which is returning a stringbuilder. The calling function will append the return value to a main stringbuilder. Main stringbuilder will be around 200 KB and the stringbuilder within functions will be around 100bytes. Will that be a better way to initialize the stringbuilder with some expected values.
Thanks,
K.P.Kannan
|
|
|
|
|
If you know the size of the StringBuilder I would initialize it with that size or a little more for efficiency but in general StringBuilders are just more efficient as they are. You dont necessarily have to use "expected values" though.
CleaKO
"Now, a man would have opened both gates, driven through and not bothered to close either gate." - Marc Clifton (The Lounge)
|
|
|
|
|
hai all,
i am using .net 2003.i want to update and save the changed values permanently in sqldatabase through datagrid during runtime in vb.net windows form.
using the following code can't update and can't save the changed values permanently.but i run this program, didn't show any error.plz any body help.
Try
Dim myChangedDataset As DataSet = Me.DataSet41.GetChanges
If Not (myChangedDataset Is Nothing) Then
Dim modifiedRows As Integer = Me.SqlDataAdapter1.Update(myChangedDataset)
MessageBox.Show("Database has been updated successfully: " + modifiedRows + " Modified row(s) ", "Success")
Me.DataSet41.AcceptChanges()
fnRefresh()
Else
MessageBox.Show("Nothing to save", "No changes")
End If
Catch ex As Exception
MessageBox.Show("An error occurred updating the database: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.DataSet41.RejectChanges()
End Try
|
|
|
|
|
I would suggest using a breakpoint and taking a closer look at your SqlDataAdapter1 just before the update. Make sure the connection is set properly and make sure your commands are set properly. Otherwise this code doesn't have any obvious problems that I can see.
Hope this helps.
|
|
|
|
|
Hi sathyan,
just a few questions to better understand your problem:
1) Do you use a SqlCommandBuilder to create your commands in SqlDataAdapter or create them manually ?
2) In the first case, is your query based upon one table or uses joins ?
I had the same problem and found that SqlCommandBuilder works only for 1-table queries.
Bye,
Advansis
Peace!
|
|
|
|
|
Hello,
I have imported Windows Script Host in my project, because of the CopyFolder() function. But, is my program legal when i have imported Windows Script Host (IWshRuntimeLibrary) and can i still distribute it?
(Maybe someone of Microsoft could answer this question?)
Thanks in regard,
--Zaegra--
|
|
|
|
|
Hi Zaegra,
a. That is not a VB programming question, so you might have better luck on a different forum.
b. If you feel someone from Microsoft is best equipped to answer you question, ask them, not us.
c. As a general rule of thumb: if your application will make people buy MS Windows (because that is the only environment your app will run in), the Microsoft people don't complain. (I'll deny everything if you get pulled into court though)
Good luck,
Johan
My advice is free, and you may get what you paid for.
|
|
|
|
|
hello frnds,
i have a big code in vb and i just want to convert that code in vb.net
is there is any site,which is do the conversion directly..
or isthere is any way to convert the whole code in to vb.net
regards,
koolprasad2003
Be A Good S/W Eng... Life is swing with you..Enjoy..
|
|
|
|
|
There is no site to do this. It's built into Visual Studio .NET. All you have to do is open the VB6 project's .VBP file to start the conversion wizard.
It will NOT do a perfect conversion. It's simply impossible to get everything correct. I HIGHLY recommend just rewriting the project from scratch, or doing the conversion and rewriting the project piece-by-piece.
|
|
|
|
|
Hi Everyone:
Thanks to Guffa and Dave Kreskowiak, the light of understanding finally broke through the fog in my head about the mechanics of the DataSet.
While exploring the internet trying to find some examples on the use of datasets and so forth I came across an artical saying to set the Autoincrement seed to zero and set the AutoincrementStep to minus one.
As I understand it records written to the dataset from the database will have positive numbering and new records added to the dataset will have negitive numbering.
So if I understand this right data returned from the database will look like:
1 Record 1
2 Record 2
3 Record 3
.
.
.
And new records appended to the dataset will look like:
-1 Record 4
-2 Record 5
-3 Record 6
.
.
.
Does anyone know the link to this artical? I spent a few hours yesterday afternoon trying to locate the artical, but I couldn't find it.
Thanks,
Quecumber256
|
|
|
|
|
Hi, I'm writing a MS Access app for a client, and using the Send Object from DoCmd works fine in sending email. The issue here is, I want to be able to have certain options already checked off so the user doesn't have to do it every single email. For example, I would like 'high priority' already clicked, 'request read receipt' already clicked, and to be able to automatically set a 'reply to' email. Is this possible with the DoCmd call, or should I be looking elsewhere to help with my emailwing woes?
-
reegan41
-- modified at 9:09 Friday 25th May, 2007
|
|
|
|
|
You know how on some websites..say if you're filling out an application that is flash driven or something, that as you go through the different screens (or steps), there are tabs at the top with a label briefly describing what that step is. So for example, when you're purchasing something online, and the first step is putting it in your 'shopping cart' in a tab at the top of the screen or whatever, then when you go to the next screen, the next tab would highlight and say 'payment method', then at the next screen, the following tab would highlight and say 'billing address', etc.
Long story short: is there (that you know of) an ActiveX (VB) control that would allow me to utilize this kind of object within MS Access?
-
reegan41
|
|
|
|
|
hi
I want to use the crystal report in my application on the basis of dataset.
I have done it with dataset having single table but having this error with more than one table :
"Query Engine Error"
Here is the Code:
Dim DS As New DataSet
Dim Cnn As New SqlClient.SqlConnection
Dim DA As New SqlClient.SqlDataAdapter
Cnn.ConnectionString = "data source=sofsrv02\development;" _
& "initial catalog=Northwind;persist security info=False;" _
& "user id=sa;Pwd=;workstation id=aliraza;Pooling=false;packet size=4096"
Cnn.Open()
DA.SelectCommand = New SqlClient.SqlCommand("Select A.PRODUCTID,A.PRODUCTNAME,B.SUPPLIERID,B.COMPANYNAME from SUPPLIERS B,PRODUCTS A WHERE A.SUPPLIERID=B.SUPPLIERID", Cnn)
DA.Fill(DS)
Dim oRpt As CrystalReport1 ' create new report object
oRpt = New CrystalReport1 ' create new instance of the report object
oRpt.SetDataSource(DS) ' set the reports data source
CrystalReportViewer1.ReportSource = oRpt ' set the viewers report source
It executes all the code but finally give me error.
Kindly Solve this Problem
Regards
Ali
|
|
|
|
|
hi,
What type of error u Face ? What is the Message of error ? Explain In Detail.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
This is the complete error.
Error in File C:\DOCUME~1\ALIRAZ~1\ASPNET\LOCALS~1\Temp\temp_2d2350fe-39ee-4e43-a51c-2503df13defd.rpt: Query Engine Error
|
|
|
|