|
try this....
in ur code page in the top of the page wrie
Imports System.Data.oledb
like this...
Imports System.Data.oledb<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form
and in ur button
Protected Sub btnCommit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCommit.Click<br />
<br />
Dim MySql As as new oledbcommand<br />
mysql.Connection = OleDbConnection1<br />
oledbconnection1.Open() ' open connection<br />
<br />
my sql.commandtext = "Insert into ExpenseReport _ <br />
(DateRow1,WhomRow1,CCardAmountRow1,PCardAmountRow1,CashAmount,VehicleNumRow1,ProjectnameRow1, _ <br />
TypeofExpenseRow1) values( " tbxDate.Text.ToString & "," & tbxWhom.Text.ToString & "," & _ <br />
tbxCCard.Text.ToString & "," & tbxPCard.Text & "," & tbxCash.Text & "," & tbxVehicle.Text & "," & _ <br />
tbxProject.Text.ToString & "," & ddnExpense.SelectedValue.ToString)<br />
<br />
mysql.ExecuteNonQuery()<br />
oledbconnection1.close()<br />
End Sub<br />
End Class<br />
that if u create ur connectin by the wizard and as i know the wizard allready will give u name of ur connection as (oledbconnection1)
i hope that will work
rusashksa@yahoo.com
Sally<<<>>>tAkE mE 2 uR pAraDiSe<<<>>>Sally
|
|
|
|
|
No offense but I see no difference in the code you posted than that of mine.
ONly things is your making it a shortcut by using Imports System.Data.oledb
and your making a Oledbconnection which is what I'm doing in my code
the connection string is write all that works
the issue is the insert string.
I use this same syntax with other dataaccess the only problem is the insert string its formated wrong and i'm not sure what i'm doing wrong.
Win32newb
"Programming is like Sex, make a mistake and you end up providing support for a long time"
|
|
|
|
|
MeterMan wrote: Dim MySql As String = "Insert into ExpenseReport _
(DateRow1,WhomRow1,CCardAmountRow1,PCardAmountRow1,CashAmount,VehicleNumRow1,ProjectnameRow1, _
TypeofExpenseRow1) values " & tbxDate.Text.ToString & "," & tbxWhom.Text.ToString & "," & _
tbxCCard.Text.ToString & "," & tbxPCard.Text & "," & tbxCash.Text & "," & tbxVehicle.Text & "," & _
tbxProject.Text.ToString & "," & ddnExpense.SelectedValue.ToString
I've seen this WAY too many times... Junk like this just leads to problems that are difficult to find and opens you up to Injection attacks.
You can avoid this by using Parameterized Queries instead. Search the articles for "Sql Injection Attacks" and you'll find a great article by Colin Angus Mackay, which will detail how to do this.
Anyway, you're missing some quote marks, concantenation characters (&), parenthesisin the SQL statements, ..., and it just bugs the #&@% out of me to see people calling .ToString() on a Text property. Text returns a String, so why call .ToString() on a String?!?!?
Dim MySql As String = "Insert into ExpenseReport " & _
"(DateRow1, WhomRow1, CCardAmountRow1, PCardAmountRow1, " & _
"CashAmount, VehicleNumRow1, ProjectnameRow1, TypeofExpenseRow1)" & _
" values (" & tbxDate.Text & "," & tbxWhom.Text & "," & _
tbxCCard.Text & "," & tbxPCard.Text & "," & tbxCash.Text & "," & _
tbxVehicle.Text & "," & tbxProject.Text & "," & _
ddnExpense.SelectedValue.ToString() & ")"
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the reply and also the word of warning on injects I will read that.
One question. How do you make the page accept the changed values n a dropdownbox only when you hit commit button.
Basically ddnExpense.SelectValue is changed and the other values are put into the text boxes but the pages has no idea what the value of ddnExpense is because it hasn't postedback. The thing is I don't want it to post back when i make a change in the dropdown because then Id loose all the data in my other fields.
Any help on this would be great.
Win32newb
"Programming is like Sex, make a mistake and you end up providing support for a long time"
|
|
|
|
|
hello friends....how r u?
well i've 3 tables in access and i wanna connect with them by vb.net .....any help plzzzzzzzzzzz
see my codes...
in buttun btnsearch , i used select command to search about information about patiend by his name then display that in textboxes as......
Private Sub Btnsearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btnsearch.Click<br />
Dim Sel As New OleDbCommand<br />
Dim R As OleDbDataReader<br />
Sel.Connection = OleDbConnection1<br />
Sel.CommandText = "select* from [patients appointment] where ([patient_name]=" & TxtName.Text & ")"<br />
OleDbConnection1.Open()<br />
R = Sel.ExecuteReader<br />
If R.Read Then<br />
TxtName.Text = R.GetValue(0)<br />
TxtFleNum.Text = R.GetValue(1)<br />
TxtDate.Text = R.GetValue(2)<br />
TxtDoName.Text = R.GetValue(3)<br />
TxtClinic.Text = R.GetValue(4)<br />
TxtNote.Text = R.GetValue(5)<br />
Else<br />
MsgBox("we can't find any date about the selected name")<br />
End If<br />
OleDbConnection1.Close()<br />
R.Close()<br />
End Sub
well... i used up to search about patient and display his information from 1 table, but that patient have another information in another table and i wanna display that in textbox...how can i do that in button of search??
i hope u understood me and i can find answers
Sally>>>><<<<take me="" 2="" ur="" paradise="">>>><<<
|
|
|
|
|
Hi,
I've got a rather old DLL (built with VS2003) that compiles properly with the 'Multi byte
charset' option under VS2005. Now, I cannot call any functions of this dll
out of a VB .net application (would need 'Use Unicode' option for that..).
As I do not want to rewrite the whole application for unicode usage: Is there
any way to call functions out of this DLL in a .net 2.0 application?
Thanks,
Peter
|
|
|
|
|
hi.
how i can datagrid receive barcode from barcode-scanner.
how i can my application receive callerid from linephone
please please sample code and details.please
123
|
|
|
|
|
The barcode scanners ive used in the past have all had an API (usually a COM control) used for capturing data from a scanner.
no idea what a linephone is
|
|
|
|
|
|
What do you mean when you are saying that it highlights the line? What is happening? What is the problem?
---
b { font-weight: normal; }
|
|
|
|
|
Hi Campbells,
I think u r right.
Access has a limited data holding capacity than SQL of not more than 10,000 records per table.
Thanx & Regards.
Success is not a Destination,
... But a Journey !!
|
|
|
|
|
Hi Vikrant
I'm not sure about the limitation you mentioned about access since I already have an access database having a table of more than 11,500 records...
|
|
|
|
|
Hi, I'm uninstalling VS 2003 so that I can Install VS 2005 Pro.
(This is happening as I type)
It's been on this[^] screen for about an hour.
How can I speed it up?
Did it crash?
|
|
|
|
|
Hard to tell.
Try restartign the uninstall program.
btw: you do know you can have VS 2003 and VS 2005 on the same machine?
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
I killed the process which apparantly corrupted the uninstallation coz now none of the setup's function works.
Cant add/remove components, can't repair vs, can't uninstall.
Oh and my IIS is very unstable, again.
Who's joining me? I'm going to Bill Gate's house tonight to throw out all his windows!!
Thank for the tip, at least I can install VS 2005 then!
|
|
|
|
|
For future reference, there is a forum here dedicted to VS issues. This forum is more VB/VB.NET coding issues.
|
|
|
|
|
Really?? Too bad Bill can't control whatever else you have installed on the machine that might have messed with the huge number of components that VS installs and other stuff that it depends on...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote: whatever else you have installed on the machine...
My machine is out of the box, only components i installed so far was SQL2000, Norton Internet Security 2004, Windows Defender and Thunderbird.
Oh, and VS 2003, which I want off now, 3 days after installing it.
What I need is something that can fix the corrupted installation package, so that I can use my repair function.
Really can't think what could've messed up my installation, don't think Bill has an excuse.
Im running both 2003 & 2005 so I'll be rid of 2003 in a year or so when I format or upgrade again.
|
|
|
|
|
Hello,
I have made a dataentry in datagrid, I just wanted to know is there any property or way that will scroll the datagrid after 4 entries or any number of fixed entries as I am using the datagrid for dataentry I want it to scroll downward as I am entering it
Thanks in advance.
Regards
|
|
|
|
|
Hello,
I made a small project with datagrid and tabcontrol till yesterday everthing was fine but yesterday when i was running my project it got hanged. Now when I am debugging this project its ok but when I am closing the project it gives me this error
"The Following exception has occured
NUllreference Exception: Object reference not set to an instance of an object.
okbutton.
then it closes. Kindly help me to trace this error as on debug it doesnot show and even when i created a setup file and used it no error. This error occurs only when I close only this project in vb. I tried to check each and every codes but no errors. How can i find where is this error coming from
Thanks in advance
Regards
|
|
|
|
|
i have a small application in vb 6.0 that can connect to any Microsoft SQL Server db and run queries on it.But i have to hard code the Server and DB name in the code.How can i pass this information i.e server and DB name from the application.
drajkhowa
|
|
|
|
|
Make a textobx in which you will enter the information?
Make a configuration file in which you will store the information?
--------------------------------------------------------
My development blog
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
strDatabase = "MyDataBase"
strServer = "MyServer"
strInstance = "Data"
strConnect = "DRIVER=SQL Server;" _
& "Trusted_Connection=Yes;" _
& "DATABASE=" & strDatabase & ";" _
& "SERVER=" & strServer & "\" & strInstance
con.ConnectionString = strConnect
con.ConnectionString = "Provider=SQLOLEDB.1;" _
& "Password=;" _
& "Persist Security Info=True;" _
& "User ID=sa;" _
& "Data Source=xyz"
Thanx & Regards.
Success is not a Destination,
... But a Journey !!
|
|
|
|
|
... and I think in VB 2005.
Why does it not expand all collapsed regions when you select Toggle All Outlining. This works in C#.
Kevin
|
|
|
|
|
Hello. I was successfully able to convert VB6 to VB.Net, however I get an error when calling a declare function. Part of the code looks like this:
<br />
Declare Function iRasEnumDevices Lib "rasapi32.dll" Alias "RasEnumDevicesA" (ByRef lpRasDevInfo As Integer, ByRef lpcb As Integer, ByRef lpcDevices As Integer) As Integer<br />
Declare Sub iCopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef hpvDest As Integer, ByRef hpvSource As RASDEVINFO, ByVal cbCopy As Integer)<br />
Declare Sub iCopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef hpvSource As RASDEVINFO, ByRef hpvDest As Integer, ByVal cbCopy As Integer)<br />
<br />
Public Structure RASIPADDR<br />
Dim a As Byte<br />
Dim b As Byte<br />
Dim c As Byte<br />
Dim d As Byte<br />
End Structure<br />
<br />
Dim lpRasDevInfo As New RASDEVINFO<br />
Dim lpcb As Integer = 0<br />
Dim cDevices As Integer<br />
Dim t_Buff As Integer<br />
Dim nRet As Integer<br />
Dim t_ptr As Integer<br />
Dim i As Integer<br />
<br />
lpcb = 0<br />
lpRasDevInfo.Initialize()<br />
lpRasDevInfo.dwSize = Len(lpRasDevInfo) + (Len(lpRasDevInfo) Mod 4)<br />
<br />
nRet = iRasEnumDevices(0, lpcb, cDevices)<br />
<br />
t_Buff = GlobalAlloc(GPTR, lpcb)<br />
<br />
iCopyMemory(t_Buff, lpRasDevInfo, Len(lpRasDevInfo))<br />
<br />
nRet = iRasEnumDevices(t_Buff, lpcb, lpcb)
I get an error on the line nRet = iRasEnumDevices(t_Buff, lpcb, lpcb) that says:
"Object reference not set to an instance of an object". I ran the debugger and the only thing that gets set to Nothing is the parameter I pass in ByRef. I'm not really sure what is going on, but does anyone have an idea?
Mike - I love to program!
|
|
|
|
|