|
Does the SQL that was used to return the data from the database return that table's Primary Key column?
|
|
|
|
|
In the code you posted, you create a new DataRow, but you never do anything with it.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Row As DataRow = ProjectsDataSet1.Tables("Projects").NewRow()
........................
........................
........................
Me.Close()
End Sub
To try to get this working I will suggest a solution using the code that you already have.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Row As DataRow = ProjectsDataSet1.Tables("Projects").NewRow()
Row("FirstName") = textBoxFName.Text
Row("LastName") = textBoxLName.Text
ProjectsDataSet1.Tables("Projects").Rows.Add(Row)
Try
Me.Validate()
Me.ProjelerBindingSource.EndEdit()
Me.ProjelerTableAdapter.Update(Me.ProjectsDataSet1.Tables("Projects"))
MessageBox.Show(ProjectName.Text & vbCrLf & vbCrLf & "identified!")
Catch ex As Exception
MsgBox("Identification is not successful.")
End Try
Me.Close()
End Sub
I have not tested this but it should work. Give it a try and get back, if not.
You do realise that your Me.Close() line will close the form, don't you?
Possibly a better way to do this is to give the users a 'New' button. When this is clicked, add a new row to the table and leave it blank. Then since your data entry controls are bound to the table they will be looking at this empty row so that when data is entered into the controls it will also be added to the table. You could then use your Button1_Click as it is except for the NewRow() line, which will no longer be needed.
Hope this makes sense, and helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks Henry!
Yes I did it with the way as you have suggested but it is not working at all.
I don't understand why do I have to assign a new row for the table if I have already bind all the fields in the form to fields in the table in dataset. Whenever validation occurs in the form, I assume that it should create a new row in the table in dataset. Am I wrong about it?
The otherwise it doesn't make enough sense to use dataset because I have to add statetements for each row e.g (Row("Name") = ProjectName.Text).
I could solve the problem with SQL and dataadapter but my aim is to learn how to use dataset.
The table is empty ib both dataset and database. I am trying to create the first record with the use of dataset and then transfer dataset to database.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
You may have already seen this but in case you haven't, take a look at How to: Insert New Records into a Database[^] on MSDN.
JUNEYT wrote: I don't understand why do I have to assign a new row for the table if I have already bind all the fields in the form to fields in the table in dataset.
You have to assign a new row so that there is somewhere for the new data to go. An empty table has no rows and therefore does not have anywhere to put your data. If your table already has data, your controls will be showing that data and any changes to their contents will change the existing data, therefore requiring a new row as before.
Something has occurred to me. When I was starting out with DB stuff, I had a similar mysterious problem. In my case it was something really silly. You might want to check this for your application. If you select your database in Solution Explorer then hit F4, the Properties Window will open for the file. Fairly near the top you should see a 'Copy to Output Directory' entry. Is that set to 'Copy Always'? If so, change it to 'Copy if Newer' because otherwise what happens is that every time you run your app, the empty DataBase is copied over the one with the data in it. Oh how I laughed, when I found that. NOT!!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi Guys,
im not sure if this is possible,
Say for eg. I have an application running which has a global variable "User" Declared.
i want to retrieve the value stored in "User" from another application.
how can this be done?
if so, can you direct me to the link?
much appreciated,
thanks
Anoop
|
|
|
|
|
Anoop Brijmohun wrote: I have an application running which has a global variable "User" Declared.
i want to retrieve the value stored in "User" from another application.
how can this be done?
You cannot just reference it like any other variable. You actually have to have some kind of communication mechanism in place that both applications support. Though, for the value of a single variable, it sounds like some bad design choices were made designing these apps and setting up communication just to transfer a single value is overkill.
Another possibility, though not available until .NET 4.0, would be a memory-mapped file. Both applications basically "share" a common file that exists in memory and can read/write to that file. Though, if sychronization is needed, you'll also need some kind of mechanism in place, depending on your requirements.
I would think you need to go back as see if the value can be stored in a well-known place and retrieved by both apps as needed.
|
|
|
|
|
Hi
Thanks For You Response.
The App 1 is not my application, its part of an ERP System created by someone else.
Within the App1,there are variables that can be called by built in script editors.
mmmm... just thought there might be a simple way to access that specific variable.
The whole idea behind was that i was building an app [2] to run automated task
and instead of the user logging in again, i would be able to get the logged in user from app1 and process.
thanks.
Anoop
|
|
|
|
|
If you have no control over App1, you've pretty much out of luck. Unless that app exposes some kind of COM interface that you can use to get at the variable.
|
|
|
|
|
Supose I have default windows printer always in Pause because I want to control jobs send by users.
Using system.printing I detect jobs and I want to decide if this may be printed or not.
If I decide to print I want to send the job to another on-line printer.
Is possible to change a job in default printer queue to another printer queue ?
The job depends on printer and the on-line printer must use the same driver or the printer may be different ?
|
|
|
|
|
edmonson wrote: Is possible to change a job in default printer queue to another printer queue
No. Once the job is created, it cannot be changed. You'd have to kill the job and have the application that generated it send it again using the new printer (good luck with that part, you'll need it!)
|
|
|
|
|
|
|
This sounds like a horrifying user interface design. but, whatever, it's your customer...
Ask this in the ASP.NET forum. What you're asking really has nothing to do with the language you're writing this in, but the web technology you're using.
|
|
|
|
|
Dear all,
I want to know about the Local Language Settings in VB 6 application.
I have one application in VB6 which i need to interpret with My Local Language in to my application Front Screen. Can anybody having the info please let me also know.
Thanks in advance.
Jay
|
|
|
|
|
|
It's called "localization". All you have to do is Google for "vb6 localization" and you'll come up with an ever-dwindling list of articles to read.
VB6 is dead and has been for quite some time now. I strongly suggest downloading VB.NET 2008 Express Edition, since it's free.
|
|
|
|
|
Good Time for U all,
I am working on an application, I want to read data from excel based on conditions like for example "select somecolumns from [excelsheet$] where acolumnname="somevalue". Is that possible to do so. Can anyone help me in do so or give me other clues for my purpose.
With regards,
|
|
|
|
|
|
Hi,
i have below short code in C#
public delegate void MsgEventHandler(object sender, ChatEventArgs e);
public static event MsgEventHandler ChatEvent;
private void Message(ChatEventArgs e)
{
MsgEventHandler temp = ChatEvent;
if (temp != null)
{
foreach (MsgEventHandler handler in temp.GetInvocationList())
{
handler.BeginInvoke(this, e, new AsyncCallback(EndAsync), null);
}
}
}
and when we translate in vb.NET
Public Delegate Sub MsgEventHandler(ByVal sender As Object, ByVal e As ChatEventArgs)
Public Shared Event ChatEvent As MsgEventHandler
Private Sub EmergencyMessage(ByVal e As ChatEventArgs)
Dim temp As MsgEventHandler = ChatEvent
If temp <> Nothing Then
For Each handler As MsgEventHandler In temp.GetInvocationList()
handler.BeginInvoke(Me, e, New AsyncCallback(AddressOf EndAsync), Nothing)
Next
End If
End Sub
but i have error, Saying ChatEvent is an event and can not be called directly.Use a 'Raise Event' statement to raise an event.
can u help me to figure it out from c# to vb.net?
thank you
regards
Sri
|
|
|
|
|
I think if you google Raise Event, you'll see the correct syntax.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Two ways to get the correct syntax.
1 - Read the documentation or search with the error message.
2 - Compile your C# application, open the assembly using reflector and change language to VB.NET.
|
|
|
|
|
Thanks Navneeth,
Can you please expline how to do this. I am new to vb.net. Please.
|
|
|
|
|
Hi whats the equivalent to below code in vb.net
string culture = ((((Range)_ws.Cells[2, (int)ExcelColumnIndexEnum.CultureColumn]).Value2 != null) ?
((Range)_ws.Cells[2, (int)ExcelColumnIndexEnum.CultureColumn]).Value2.ToString().Trim() : string.Empty);
I tried to convert using a tool available in developerfusion that gives me
Dim culture As String = (If((DirectCast(_ws.Cells(2, CInt(ExcelColumnIndexEnum.CultureColumn)), Range).Value2 IsNot Nothing), DirectCast(_ws.Cells(2, CInt(ExcelColumnIndexEnum.CultureColumn)), Range).Value2.ToString().Trim(), String.Empty))
but when i paste in vb editor it shows error.
ExcelColumnIndexEnum is an enum and codes are as.
Imports System
Imports System.Collections.Generic
Imports System.Text
Public Enum ExcelColumnIndexEnum As Integer
CultureColumn = 1
OtherColumn=2
...
End Enum
please help
|
|
|
|
|
This is horrible code, why would you want to convert it ? What error does it show ? I think the If should be Iif, then I think it might work.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I think the error is he is posting C# code into a Visual Basic .Net project...
and yeah, that should be IIF as well.
|
|
|
|