|
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
|
|
|
|
|
First, the command line that you're actually running is C:\\test.bat . The two backslashes next to each other work, but could cause you problems later if used indiscriminatly.
Second, the working directory is the directory from where your code is launched. Like Luc said, you have to set the WorkingDirectory[^] property of the ProcessStartInfo object.
Dim psi As New ProcessStartInfo(Path.Combine(TextBox1.Text, "test.bat"))
psi.WorkingDirectory = TextBox1.Text
Process.Start(psi)
|
|
|
|
|
kubben, i removed one of the \ but that didn't fix it. Its still running from the debug folder.
quote: Just to clarify, is it running c:\test.bat, but performing tasks on the debug folder?
Thats right. Its running from the debug folder, i want it to run from C:\
Luc and Dave, that did it!
Thanks to all of you for your quick answers.
http://www.themightyatom.nl
|
|
|
|
|
I have one menu control in my Main Page and menu has 5 menu items, I have one ASPX page which as one button. Initially 2 menu items in the menu will be disabled. On click of button in the aspx page those disabled menu items should be enabled. But it is not working. Bellow is the code for enabling the menu items.
Protected Sub Sumbit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Sumbit.Click
Dim mnControl As Menu
mnControl = CType(Master.FindControl("Menu1"), Menu)
mnControl.Items(0).ChildItems(4).Enabled = True
mnControl.Items(0).ChildItems(5).Enabled = True
mnControl.Items(0).ChildItems(3).Enabled = True
end sub.
Kalyan
|
|
|
|
|
are you getting an error message?
at first sight I would think you're childitems index just be 2,3,4 but normally you should get an index out of range exception
|
|
|
|
|
Some rethorical questions:
how many ChildItems are there ?
are there just buttons ?
how can you tell what the indices are for the buttons you want ?
|
|
|
|
|
I have some project which was built on VB4.0. But i dont have VB4.0, and i want to migrate to the latest vb5.0 or vb6.0 version.
How can i do it?
Thanks in advance.
Regards,
Kamalasubramanian
Kamal
|
|
|
|