|
'Declare the form
Dim oFrm as new frmXXX
'Open the form as a dialog and get the result
if FrmXXX.showdialog(me).dialogresult = Ok Then
sText = oFrm.Textbox1.Text
End If
oFrm.Close
Trick is to HIDE the form in the Ok/Cancel buttons
|
|
|
|
|
Yep, that is the better solution
My advice is free, and you may get what you paid for.
|
|
|
|
|
You should never create 'global' variables, if you can avoid it, nor should you ever expose a UI element as public. You should always expose as little as possible, so in this case, expose a property, which is of type string, and have it return or set the Text property of the specific textbox.
Or, if the first form is creating the second, you can force the setting of this property by passing it through the constructor.
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 )
|
|
|
|
|
iam using vb2005 and microsoft access as database
making database application
and i made this code in form1 and i need the same code but there was some different in the fields
and when i typed it in form2 it didn't work i don't know why
plz help me it's very urgent
i will appreciate all ur efforts
thanks
|
|
|
|
|
sorry the code is
GC.Collect()<br />
<br />
cmd.Connection.Close()<br />
<br />
<br />
If cn.State = ConnectionState.Closed Then<br />
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=ehab.mdb"<br />
cn.Open()<br />
<br />
End If<br />
<br />
<br />
cmd.Connection = cn<br />
cmd.CommandType = CommandType.Text<br />
<br />
<br />
<br />
<br />
Dim h As Integer<br />
Dim s As String<br />
s = 0<br />
h = 0<br />
<br />
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & "',"<br />
<br />
f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & "," & f7 & "')"<br />
<br />
cmd.CommandText = s<br />
cmd.ExecuteNonQuery()<br />
MsgBox("Saved succssefuly")
iam sure it's not wrong
he tell me always ( Syntax error in INSERT INTO statement.)
while the same code was waorking in the form1
plz help
|
|
|
|
|
From what I can see the sql statement would read
INSERT INTO Sale (dte,op,nos,cost,coms,nii,npp) VALUES
('xxx','xxx','xxx','xxx','xxx','xxx','xxx',')
The last value is f7 which is followed by a comma, which shouldnt be there since it is the last item in the list. You also have a ' before the bracket which again is not needed and will cause a syntax error.
If you were to put a breakpoint on the line
cmd.CommandText = s
And watch the value of s you would be able to see the SQL so you could check the syntax.
Hope that helps.
Simon
|
|
|
|
|
SHatchard wrote: If you were to put a breakpoint on the line
cmd.CommandText = s
And watch the value of s you would be able to see the SQL so you could check the syntax.
thanks for ur reply
i have made breakpoint to see the values every one have the value that entered in textbox and combobox ....
and i have correct the code as u said but the same error
here is the correction that i wrote
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & "',"<br />
<br />
f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"<br />
<br />
cmd.CommandText = s<br />
cmd.ExecuteNonQuery()<br />
MsgBox("Saved succssefuly")<br />
<br />
if u have another SOLUTION plz tell me
thanks a lot
|
|
|
|
|
i tried to write this code insted of the other one
s = s & "(" & f1 & f2 & f3 & f4 & f5 & f6 & f7 & ")"<br />
but it didn't work
|
|
|
|
|
You still have a comma after
f7 = "'" & TextBox4.Text & "',"
as I mentioned earlier, and in your command you do not have a parameter after that which is a syntax error.
In the code above you also still have a single quote ' after the last parameter as well. The reason I suggested the breakpoint was so that you could validate the syntax of the SQL statement.
If you are still having problems after looking at that please copy the contents of s at the breakpoint into a message here
|
|
|
|
|
here the code is it write ??
Dim f1, f2, f3, f4, f5, f6, f7, f8 As String<br />
<br />
f1 = "#" & DateTimePicker1.Value & "#,"<br />
<br />
f2 = "'" & ComboBox1.Text & "',"<br />
<br />
f3 = "'" & ComboBox2.Text & "',"<br />
<br />
f4 = "'" & TextBox1.Text & "',"<br />
<br />
f5 = "'" & TextBox2.Text & "',"<br />
<br />
f6 = "'" & TextBox3.Text & "',"<br />
<br />
f7 = "'" & TextBox4.Text & ""<br />
<br />
' f8 = "'" & Label10.Text & "'"<br />
<br />
s = "insert into sale"<br />
s = s & " (dte,op,nos,cost,coms,nii,npp)values "<br />
<br />
' s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & f7 & "')"<br />
<br />
s = s & "(" & f1 & f2 & f3 & f4 & f5 & f6 & f7 & ")"<br />
<br />
the error msg is :Syntax error in string in query expression ''12.75)'.
and here the breakpoint :
"insert into sale (dte,op,nos,cost,coms,nii,npp)values (#7/2/2007#,'Mobinil','10','1','13','0.25','12.75)"
|
|
|
|
|
Change
f7 = "'" & TextBox4.Text & ""
to
f7 = "'" & TextBox4.Text & "'"
and it should work fine then, you only needed to remove the comma
|
|
|
|
|
Thanks very very very much it works well
u r helpful
|
|
|
|
|
magedhv wrote: GC.Collect()
Why are you doing this ?
magedhv wrote: f2 = "'" & ComboBox1.Text & "',"
magedhv wrote: s = s & "(" & f1 & "," & f2 & "," & f3 & "," & f4 & "," & "," & f5 & "," & "," & f6 & "," & "," & f7 & "')"
This is kind of ridiculous. You're just creating far more strings than you need to, and making the code hard to debug. No wonder there's a syntax error in your insert statement. Try using a string builder, or at least build the query all in one line.
Also check your final string in the debugger if you get an error like this, to see if it's legal SQL ( it plainly isn't )
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 )
|
|
|
|
|
hello frnds,
i want to add the check box to gridview header to implement the select all facility
how can i do this.....plzzz help
any idea ?????
any helpful link ????
regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
You will need to create a custom header style:
http://msdn2.microsoft.com/en-us/library/ms748988.aspx
Have a read through that and if you get stuck give me a shout.
Dan
|
|
|
|
|
Hi! this is an emergency.
I have made a software that uses many fonts, transparency options in the skin and many more settings that works well on my computer as it has all the necessary fonts and .net framework 3 but when running on other machines
1)They don't have the fonts I've used.
2)They only have .net framework 2.(in my class)
3)I have used a background image and made yellow as the transparent key this works well on my machine but on other machines the yellow edges of the background are visible.
I heard you can embed all the necessary system files with application on compiling, but I searched everywhere and couldn't find a single detailed explanation anywhere so I came here as a last resort.
So, Pls someone help me.
|
|
|
|
|
Hi,
I have created a windows application using VB.NET its working fine there is no issue on that applicaiton. My problem is i want to restrict multiple times of running the same application. for example if i click and run the exe file it will open the application again click on the same exe file it will open the same application second time. I want to restrict that if u click on the exe n time it should open one not many. is it possible if so can u plz guide me how to do that.
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
Hi
You can iterate though the processes running on the machine to see if one is running with the same name as the current application. Code would look like
Dim currentProcess as Process = Process.GetCurrentProcess
Dim allProcesses as process() = process.getprocessesbyname(currentProcess.ProcessName)
For each process as Process in allProcesses
If process.Id = current.Id then continue for
If [Assembly].GetExecutingAssembly().Location.Replace("/", "\") = currentProcess.MainModule.FileName Then
'There is another version running
Throw new exception("Application already open")
end if
next
Thats just entered but should give you a good idae of how to code this...
|
|
|
|
|
run this on Form1_Load
If (UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0) = True Then<br />
End<br />
End If
|
|
|
|
|
Thanks for your flying reply its working for me
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
hi,
go to Properties of Project & click on application tab
now click on checkBox related to "Make single instance application"
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
Thanks for your flying reply its working for me
Thanks
Warm Regards
Prakash-B
|
|
|
|
|
can anyone tell me where the SaveSettings function store the data in registry.
thanks
|
|
|
|
|
|
hi
i have extracted backend code of the webpage which looks some thing like this.
<title>orkut - Login
is an online community that connects people through a network of
trusted friends. We are committed to providing an online
meeting place for people to socialize, make new acquaintances
and find others who share their interests.
Join orkut now to create and connect with your own social circle.
Learn more about keeping orkut beautiful
|
| |
|
now i want to take only the the data which is in the table format and display it in tables in asp and vb.net.
i did this program. but am extracting the whole file(above code) into the tables but want to take only the data which is present in the table tags.
and also how to display a textfile data which does not have any table tags.
there is no such thing as good or bad.
|
|
|
|
|