|
|
What I want to do is, i have datatable that is populated by MySQL Table. I want to be able to bind the col to specifice text boxes. There is only going to be one row that is going to be use.
Idea i would like to do it that way. if not i can make datagrid and bind that way, i dont know the correct systex to make it work. i was looking on this website and i found an example but i does not work..Im using VB.net 2005 Express or i can do it in VB.net 2003..
I need to know to do this in code.. please
Thank you
Shane
|
|
|
|
|
The only way to do this, is to get your row, and set each textboxes text to be the contents of the columns you want them to be.
What do you mean you found an example, but it doesn't work ? If you posted the code, and what goes wrong, we'd probably be able to help a little more.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I got it to work. I used a datagrid and hide it and use this code to put into the text put into the text boxes.. this data is only for read only does not need to be use again after the program opens. its only query on speficet piece of data for that day they open the program.
dgview.rows(0).colums(0).value.tostring or something like that..
Thanks for u try to help me..
sorry, i should have post the code that i was talking about...
im very new to ask for help like this on message bords...
Thank you
Shane
|
|
|
|
|
I have two questions regarding updating an Access Database using the Update command for an OleDbDataAdapter.
1. A DataTable that has been filled using the DataAdapter Fill() command is bound to a DataGridView through the DataSource and DataMember commands of the DataGridView. After changing some values in the DataGridView, I use the DataAdapter.Update() command to record the changes in the grid in the Access Database. If I make a change to a cell and then move the cursor to another row, the change is recorded; however, if the cursor is not moved to another row, then changes made to the row in which is selection remains are not reflected in the Access Database after the Update() command. I have tried using the DataGridView commands EndEdit(), RefreshEdit(), and Refresh() and none of those commands cause changes in the most recently selected row to be reflected in the updated Access Database. Any suggestions?
2. A DataTable is filled using the DataAdapter Fill() command. Rows containing data are then added to the DataTable. After adding the rows, the DataTable is bound to a DataGridView through the DataSource and DataMember commands and then the DataAdapter.Update() is used to update the Access Database. This generates an error "Update requires a valid InsertCommand when passed DataRow collection with new rows." I cannot figure out how to use the InsertCommand(). The difficulty is likely because I don't understand how to use the CommandBuilder. Any suggestions?
Rich Feldman
|
|
|
|
|
Do you have an insert query for the InsertCommand?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
No. I do not know how to construct an insert query. To use the Fill command, I copied the following from a book without much understanding:
da = New OleDb.OleDbDataAdapter("Select * From MyTable", cn)
cb = New OldDb.OleDbCommandBuilder(da)
da.Fill(myDataSet, "myName")
where da, cn, and cb are appropriately defined variables.
The Update Command worked without needing to build any command. Any help on the InsertCommand would be greatly appreciated.
Rich Feldman
|
|
|
|
|
RichFeldman wrote: I copied the following from a book without much understanding
Ah, there is the root of the problem.
Some reading material on the insert command.
INSERT INTO W3Schools[^]
Or
Insert MSDN[^]
With respect, I must disagree. A quick look at middle management in just about any corporation shows that the dodo not only survived, it's reproducing in record numbers. Christopher Duncan
|
|
|
|
|
The SQL Statements are not the problem but the use of the DataAdapter and the CommandBuilder. Can you recommend some reading regarding those?
Rich Feldman
|
|
|
|
|
Do While lcp_objReader.Peek() <> -1
str_lcp_Tmp = lcp_objReader.ReadLine()
str_lcp_data(a) = str_lcp_Tmp.Split(lcp_delimiter, StringSplitOptions.RemoveEmptyEntries)
If str_lcp_data(a).Length > 0 Then
For index As Integer = 0 To str_lcp_data(a).Length - 1
Console.Write(str_lcp_data(a)(index) + "|")
Next
Console.Write(vbCrLf)
a += 1
End If
Loop
i would like to print out the row 120, so i put
Console.Write(str_lcp_data(120)(index) + "|")
After debug, it gave the message "object reference not set to an instance of an object". How come it become like this?
If i want to print the rows after row 120 (from 121 until end of the file), should i initialise a to 120 before do while loop?
|
|
|
|
|
this usualy accurs when you forget the initialize the object (the new keyword)
for example:
<br />
Dim ll As List(Of String)<br />
ll.Add("test")
--> will give you're error
<br />
Dim ll As new List(Of String)<br />
ll.Add("test")
--> will not give the error
so in you're case I think you forgot to initialize the str_lcp_data object
|
|
|
|
|
i got initialise str_lcp_data object
dim str_lcp_data (1000)() as string
|
|
|
|
|
that is not initialized (I think correct me if I'm wrong)
that is declared
to initialize the variable you need to enter data
try this (just to see if this is the problem)
str_lcp_data(120)="test"
and then run and see if you still get the error if not you've found the cause wich is that there was no data to display
if you still get the error then I don't really know what is going on
|
|
|
|
|
You've created a jagged array (an array of arrays). When you do this each element points to another array. The array's initially aren't created. I think this is why you get the error. Take this for example
Dim data(5)() As String
data(0) = New String() {"Data1", "Data2", "Data3"}
Console.WriteLine(data(0)(0))
' The next line will throw an error because the 2nd element
' doesn't point to an array yet.
Console.WriteLine(data(1)(0))
What's probably happening is you are only reading x number of rows, so only the first x elements have been initialized properly. Trying to read beyond x will throw an error. You could initialize all the elements first like so:
For i As Integer = 0 To data.Length - 1
data(i) = New String() {}
Next
Or you can just make sure you don't read beyond the number of lines read.
|
|
|
|
|
I made a software with SQL server 2000 as databse in Vb.net.it works quite well.But when want run it on another computer i have to configure the windowApplication1.exe.config file and have to provide the name of the server,database,username,password manually.Can i do it grom the fron end when yhe software starts.
I want know more about .net
|
|
|
|
|
So, you chose to ignore the reply to your previous post, of the exact same question, you put up 3 hours ago?? Any particular reason??
Like the other reply said, you have to modify the connection string you saved in the app.config file. You can either do some simple string manipulation at runtime to replace the database path, username and password, ...
Or, you can modify the string in the app.config file with a configuration tool you build into your app or you build into a custom action in your app's installer. This method requires that you load the app.config as an XML document, make the changes, then rewrite the XML document back out to the app.config file.
|
|
|
|
|
Dave Kreskowiak wrote: you chose to ignore the reply to your previous post, of the exact same question, you put up 3 hours ago?
Oh please, here we go again...
Dave Kreskowiak wrote: Any particular reason?
Maybe he wants to summon some rather cranky people
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi can any one please how to write text in next line of an existing file.
I used below two methods.Itz getting appending at the last in the same line
File.AppendAllText("My file path", text to write)
(or)
My.Computer.FileSystem.WriteAllText("My file path", Text to write, True)
thanx in advance .
Is the above good practice or using FSO object ?pls give me suggestions
|
|
|
|
|
put a 'vbCrLf' (=enter) before you're text to write
File.AppendAllText("My file path", vbcrlf & text to write)
My.Computer.FileSystem.WriteAllText("My file path", vbcrlf & Text to write, True)
should work
|
|
|
|
|
Thank you very much its working dude.
|
|
|
|
|
you can also use following statement
File.AppendAllText("My file path", Controlchars.newline & text to write)
My.Computer.FileSystem.WriteAllText("My file path", Controlchars.newline & Text to write, True)
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
I don't get this at all. Here's the deal:
I have a TextBox. Its properties are:
Text: C:\
Name: TextBox1
Next to the TextBox, i have a button. This is the code under the click event:
Process.Start(TextBox1.Text & "\test.bat")
So when you click the button, the app should run the file test.bat that has been placed in the directory written in the TextBox, C:\ in this case.
The problem is that the batch doesn't run from C:\ , but from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug
Thats the folder where the debug .exe is located. Why is it running from C:\Documents and Settings\Atom\Mijn documenten\Visual Studio 2005\Projects\Test_App\bin\Debug instead of C:\ ? I need it to run from C:\
Any ideas?
|
|
|
|
|
This is just a guess, but it looks like you are pointing to:
c:\\test.bat instead of c:\test.bat
I would remove one of the \
Hope that helps.
Ben
|
|
|
|
|
Just to clarify, is it running c:\test.bat, but performing tasks on the debug folder?
or is test.bat not running at all?
|
|
|
|
|
I think you will be interested in ProcessStartInfo.WorkingDirectory
groeten
|
|
|
|