|
Thanks..
I have another setting issue with the ComboBox in the DataGrid... I wanted the combo boxes to behaive like Dropdown Combo not DropDown List
Is there a way to change the drop Down property???
|
|
|
|
|
Hi Everyone,
I'm working on window application. I'm adding a set of new rows to datagrid using a datatable.
Once completed, i want to save all the added rows from datagrid to database.
How should i save it into database??
Can anyone advice me? Thanks in advanced.
Here is the codes:-
public Sub DataGrid()
myTable = New DataTable("Exam")
Dim Employee As DataColumn = New DataColumn("Employee")
Employee.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(Employee)
Dim Score As DataColumn = New DataColumn("Score")
Score.DataType = System.Type.GetType("System.String")
myTable.Columns.Add(Score)
Dim ds As New DataSet
ds = New DataSet
ds.Tables.Add(myTable)
datagrid1.SetDataBinding(ds, "Exam")
end sub
Private Sub btnComplete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnComplete.Click
Dim strQuery1 As String
strQuery1 = "Insert into MMExam (Employee,Score) values('" & DataTable.Rows(Employee) & "','" & DataTable.Rows(Score )& "')"
myConnection.Open()
myCommand = New SqlCommand(strQuery1, myConnection)
Try
ra = myCommand.ExecuteNonQuery()
myConnection.Close()
Me.Close()
Catch ex As Exception
myConnection.Close()
MessageBox.Show(ex.Message)
End Try
End Sub
thanks,
eunice
|
|
|
|
|
A DataGrid is used to show and edit the data in a DataSource, such as a DataTable or DataSet. You don't go from DataTable to DataGrid to database. You go from DataGrid - which shows and edits a DataTable/DataSet - which synchronizes changes with a Database.
From what you've posted, your code is pretty much spaghetti.
If you're adding records to an existing database, I'd start by creating a DataSet and DataAdapter with the proper SQL statement to retrieve the fields from the table that you're going to manipulate. Use it's FillSchema method to create a new DataTable object in your DataSet object. This will automatically setup your DataTable for your, mapping the columns in the database to the columns in the DataTable using the proper data types.
Then, you use a CommandBuilder (SqlCommandBuilder, OleDbCommandBuilder, ...) on the DataAdapter to create the SQL UPDATE, INSERT, and DELETE commands for the DataAdatper.
Then bind the DataGrid to that DataTable, make your changes, then use the DataAdapter's Update method to write the changes back to the database.
|
|
|
|
|
Hi.
I want to control a electronic lock using the parallel port and I don't know how to control it using VB .Net 2008. Can you teach me how to control the parallel port?
Thanks a lot.
Merry Christmas!
|
|
|
|
|
You need a 3rd party library to directly control the hardware, something akin to a device driver. You can find one such library and some example code here[^] and here[^].
|
|
|
|
|
Hi all
I am working on a chat application in vb.net. I can specify a IP address and send message to a computer where my application is installed and running.
But i want to populate the ip address ( system in the LAN where application is running)automatically as soon as the application starts, just like any messenger(where the name of online people display in bold).
A refresh button i want to put so that as soon a new user in different machine starts the application his IP gets displayed in the application window.
Thanks and Regards
Prakash Mishra(Banglore,India)
|
|
|
|
|
Prakash_Mishra wrote: But i want to populate the ip address ( system in the LAN where application is running)automatically as soon as the application starts, just like any messenger(where the name of online people display in bold).
You'll need a central server that all the clients check into when they start. This server would keep track of the IP's for each client and give them out to the clients when they check in.
|
|
|
|
|
|
Keep the subject brief and put the question in the body of the post.
Are you saying the a "PB" is a PictureBox control or a ProgessBar? Are you trying to make a custom ProgressBar with three different colors in the bar??
|
|
|
|
|
yes thats what I'm trying to do...
I think I should create a new class to inherit from ProgressBar then add my code, but really lost my mind thinking how to this.
will appreciate some suggestions.
thank you.
Shimi
|
|
|
|
|
You'd inherit from the existing ProgressBar class, add the appropriate properties to do what you want to do, then handle the Paint event and supply the new code to paint your ProgressBar control how you want it.
|
|
|
|
|
what a shame, I have never used the paint control, and don't even know what is it's features, and what purpose can it be helpful for.
if you have some examples to show me I'll be glad to see (I know only VB.NET).
thank you!
Shimi
|
|
|
|
|
Shimi
|
|
|
|
|
Yes! You can set BackColor property of a label to transparent.
|
|
|
|
|
I'm talking about System.Windows.Forms.Label
which doesn't react correct even I set the BackColor property at run-time.
my objective is to put a label within a picture or a drawn area so it must be really transparent.
thanks for your post.
Shimi
|
|
|
|
|
Hi
I have a very large file in whose format is like this:
KEYWORD
SomeInformationLines
KEYWORD
SomeInformationLines
I need to pass through the file and save the position of each keyword, so that when later, user wants me
to read the keyword data from the file, I can seek to the position of the keyword and read the data.
The problem is some files are unix format (i.e. their lines end with linefeed, Chr(10), only rather than CR-LF, Chr(13)+Chr(10)).
This is My Code:
FileOpen(1,FileName)
Do Until EOF(1)
strLine = LineInput(1)
If IsKeyword(strLine) Then
SaveKeywordPosition( strLine, Seek(1) )
' The above line is where the bug comes from:
' e.g if the line is empty, and only an LF is in it, Seek(1) returns 2!!
' i.e. it virtually adds a CR and this is done for all further lines too.
' But whem I use Seek(1, aPreviouslySavedPosition) it goes exactly to where
' it should go, without accounting for extra CRs which it added while reading
' the file.
End If
Loop
FileClose(1)
I also have tried to with InputString function, StreamReader and FileStream classes and check the last character of
the line manually, but the IO was raises from 800KB/s to 18MB/s and runtime from 15sec to 2min.
Could someone please tell me how should I handle this?!
|
|
|
|
|
MohammadAmiry wrote: I need to pass through the file and save the position of each keyword, so that when later, user wants me
to read the keyword data from the file, I can seek to the position of the keyword and read the data.
OK. If you're using ReadLine to read the file, you won't get the LF character at the end of each line in the resulting string. ReadLine will strip the line termination characters for you. So, you simply have to add one to the character count of each line you read when you go to find each keyword.
If you have a mix of file types, then you'll have to find out what the line termination characters are. Simply read the beginning of the file, character-by-character until you find either character 10 or 13, then check value of the next character to see if it is the opposite, 13 or 10, or if neither. This will tell you if the line termination is either CrLf, LfCr, or just Cr or Lf. You can adjust your character count accordingly.
|
|
|
|
|
hi,
i create the arrary of button called (gButton(55) As Button) and in run time it stop in this error "gButton(count).Name = "R" + CStr(count)"
and error is "object refrence not set intance of object"
how can create array of button and set it the name of button ?
|
|
|
|
|
You declared an array of buttons, but the buttons are not instantiated. You need to instantiate them.
By the way, why so many buttons?
|
|
|
|
|
darkelv wrote: You declared an array of buttons, but the buttons are not instantiated. You need to instantiate them.
So in other words use the keyword "New" to instanciate it.
Pete Soheil
DigiOz Multimedia
http://www.digioz.com
|
|
|
|
|
to collocet my button in form to process them in queue
|
|
|
|
|
Merry Christmas to everyone!
Don't you know how I can get the image my form looks like?
I've tried DrawToBitmap method, but with that I didn't get the graphics, just the controls.
Please help if you can.
|
|
|
|
|
What is it you are trying to do? Put a picture on the form or as a background for the form?
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Sorry I didn't write clearly, my problem is the following:
I've a form, and controls in it. I want to get the same image that the user sees on the screen. If I don't use graphics, I can use DrawToBitmap method. But what should I do if I use graphics too???
|
|
|
|
|
Hi,
if you do the graphics correctly, you will catch it. Here is a tiny paint instruction:
there are several steps to draw something so it becomes visible on the screen:
1.
decide upon what object you want to draw; it normally is a Control (e.g. a Panel) or a
Form itself. I prefer to add a Panel to a Form, then draw on the Panel.
2.
create some variables (Rectangle, struct, class, whatever) that hold the parameters of
your drawing. For a rectangle that could be top and left coordinate, and width+height,
or just a Rectangle. etc.
3.
create a Paint handler for that Panel, and do all your drawing in there, using the
Graphics class and your variables.
4.
when you want to change things, modify the variables and call Panel.Invalidate() or
one of its overloads (for selective invalidation).
5.
If you want to animate things, perform the move (step 4) inside the Tick handler
of a Windows.Forms.Timer
BTW: if you need to create some objects (Fonts, Pens, Brushes, ...) either keep them
alive in class members (hence create them only once); or create them inside the Paint
handler and don't forget to call Dispose() on them.
|
|
|
|