Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Inserting Data In EXE File


I need to insert some data into an EXE file, which my app will read... how can I do it in such a way that the computer won't want to run it, and it won't mess up the EXE?

Maybe I can put it at the beginning, and set the pointer in the header? How do I do that? I don't have any sound information, so I don't want to try it...

Any info?

Thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Inserting Data At The Top Of A File
Hi,

I need to insert data at the top a of a file. These files can be huge and therefore I dont want to have to re-write the whole file.

I need a prepend function that will very quickly add a single line (column headings) as the first line in the file (as opposed to an Append function)

ideas?

Cheers

JAS

Inserting Data Into A Text File
Is there a way to "insert" a line of data (string variable) at the top of a text file that already contains data. I have a text file with over 500 lines of customer information and I need to insert 1 line at the top of the file that is non customer information.

Inserting Textbox Data Into A Text File
Hi Everyone

I have 16 textboxes and am trying to loop through all of them to make the code simple, and insert the data into a text file.
I have most of the code right, but I cant get the write command to see that the string is a textbox name.

My text boxes are 'AddToClientRecord1, AddToClientRecord2,....AddToClientRecord16.

The code which isn't working is

Open "C:Documents and SettingsMeezlesMy DocumentsOur DocumentsNomesHibiscus MassageClient Records" & ClientLastName & "," & ClientFirstName & ".txt" For Append As #1
AddDetails2 = 0
Do While AddDetails2 <= 15
AddDetails2 = AddDetails2 + 1
AddDetails3 = "AddToClientRecord" & AddDetails2 & ".Text"
AddDetails4 = AddDetails3
If AddDetails4 = "" Then
Else
Write #1, AddDetails4
End If
Loop

AddDetails2 is a integer, AddDetails3 is a string, AddDetails4 is a string.

The files open and close fine, but Instead of inserting the data, it simply puts
"AddToClientRecord1.text"
"AddToClientRecord2.text"......
"AddToClientRecord16.text"

Any help would be great.

Dave

Inserting Data Into The Middle Of A Binary File
what i want to do basically is insert data into a binary file without overwriting anything.

ex:

00000000: 1212 1212 1212 1212 1212 1212 1212 1212
00000016: 1212 1212 1212 1212 1212 1212 1212 1212
00000032: 1212 1212 1212 1212 1212 1212 1212 1212

to like:

00000000: 1212 1212 1212 1212 1212 1212 1212 1212
00000016: 1212 1212 1212 1212 1212 1212 1212 1212
00000032: 4444 4444 1212 1212 1212 1212 1212 1212
00000048: 1212 1212

how would i go about that?

Inserting Data Into Rich-Text File
Good Day

I have created an invoicing program in VB6 – MS-Access 2003. I have a form and using RichText control for the invoice, this one is for printing and creating a soft copy. Now the main reason why I when with a rich-text is to have the ability to email the invoice. I have another form for the email and the body of the email is using RichText control. The problem that I am having is exporting the invoice items into the rich-text file. My invoice form draws the data form another form that the user can pick the preson name and invoice number. This form uses a datagrid and Adodc ( I included some screen shots of it )


Code:

Private Sub Form_Load()

Set ConnDB = New ADODB.Connection
With ConnDB
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "Data Source=" & App.Path & "SpeedData.mdb;Persist Security Info=False"
.Open
End With

lblTemp1 = ViewPrintInvoice.lblInstaller.Caption
lbltemp2 = ViewPrintInvoice.lblInvoiceNum.Caption
Totals
LoadData

End Sub

Private Sub LoadData()
Dim Temp As String

Set rstOwner = New ADODB.Recordset

With rstOwner
.ActiveConnection = ConnDB
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.Open "SELECT * FROM Owner"
End With

Set rstTax = New ADODB.Recordset

rtbInvoice.LoadFile App.Path & "TempInvoice.rtf"

Temp = rtbInvoice.TextRTF

Temp = Replace(Temp, "toDayDate", Space(0) & ViewPrintInvoice.lblDate.Caption)
Temp = Replace(Temp, "invX", Space(0) & ViewPrintInvoice.lblInvoiceNum.Caption)

Temp = Replace(Temp, "busNameX", Space(0) & rstOwner![BusName])
Temp = Replace(Temp, "ownerX", Space(0) & rstOwner![Name])
Temp = Replace(Temp, "addressX", Space(0) & rstOwner![Address])
Temp = Replace(Temp, "cityX", Space(0) & rstOwner![OCity])
Temp = Replace(Temp, "provX", Space(0) & rstOwner![Prov])
Temp = Replace(Temp, "postalX", Space(0) & rstOwner![PostalCode])
Temp = Replace(Temp, "phoneNumX", Space(0) & rstOwner![PhoneNum])
Temp = Replace(Temp, "faxX", Space(0) & rstOwner![FaxNum])

Temp = Replace(Temp, "busNameY", Space(0) & ViewPrintInvoice.lblBusName.Caption)
Temp = Replace(Temp, "installerY", Space(0) & ViewPrintInvoice.lblInstaller.Caption)
Temp = Replace(Temp, "addressY", Space(0) & ViewPrintInvoice.lblAddress.Caption)
Temp = Replace(Temp, "cityY", Space(0) & ViewPrintInvoice.lblCity.Caption)
Temp = Replace(Temp, "provY", Space(0) & ViewPrintInvoice.lblProv.Caption)
Temp = Replace(Temp, "postalY", Space(0) & ViewPrintInvoice.lblPostalCode.Caption)
Temp = Replace(Temp, "phoneNumY", Space(0) & ViewPrintInvoice.lblPhoneNum.Caption)

Temp = Replace(Temp, "gstY", Space(0) & newGst & "%")
Temp = Replace(Temp, "pstY", Space(0) & newPst & "%")

Temp = Replace(Temp, "gstX", Space(0) & varGst)
Temp = Replace(Temp, "pstX", Space(0) & varPst)
Temp = Replace(Temp, "subTotalX", Space(0) & varSubTotal)
Temp = Replace(Temp, "totalX", Space(0) & varTotal)

rtbInvoice.TextRTF = Temp
rtbInvoice.SelStart = 1

Me.rtbInvoice.SaveFile App.Path & "Invoices" & ViewPrintInvoice.lblInstaller.Caption & " " & ViewPrintInvoice.lblInvoiceNum.Caption & ".rtf"


End Sub

Reading Text File And Inserting Data Into A SQL Table
Please help! I am getting a comma delimited text file from an outside vendor. I need to read the file, separate the sting into individual variables and insert the variables into a SQL table.
I have no problem if there is only one record but I can't seem to get my code to work when there are muliple records in this text file.

I know I need some sort of loop or do while not EOF statement. but I have not been able to get either to work.



Code:
Dim fso As New FileSystemObject, txtfile, _
fil1 As File, fil2 As File, ts As TextStream, s
Dim fldValue As Integer
Dim sLength As Integer

Dim cmdInsert As ADODB.Command
Dim cnDatabase As ADODB.Connection
Dim rsInsert As ADODB.Recordset
Dim prInsert(7) As Variant

Private Sub Form_Load()

Set fil1 = fso.GetFile("C: estfile.txt")
Set ts = fil1.OpenAsTextStream(ForReading)
s = ts.ReadAll

End Sub

Private Sub cmdOpenFile_Click()

Call getMSH
Call insertMSH

End Sub

Public Sub getMSH()

'Get the MSH Field Definition
fldValue = InStr(1, s, ",")
prInsert(0) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

If prInsert(0) = "MSH" Then

'Get the Facility ID
fldValue = InStr(1, s, ",")
prInsert(1) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

'Get the Physician name
fldValue = InStr(1, s, ",")
prInsert(2) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

'Get the ERF Request Date
fldValue = InStr(1, s, ",")
If fldValue = 1 Then
prInsert(3) = "01/01/1900"
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)
Else
prInsert(3) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)
End If

'Get the package ID
fldValue = InStr(1, s, ",")
prInsert(4) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

'Get the Transaction Type
fldValue = InStr(1, s, ",")
prInsert(5) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

'Get the number of PID records
fldValue = InStr(1, s, ",")
prInsert(6) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)

'Get the number of test
fldValue = InStr(1, s, ",")
prInsert(7) = Left(s, fldValue - 1)
sLength = Len(s)
s = Mid(s, fldValue + 1, sLength - fldValue)
Else
MsgBox "Try again"
End If

End Sub

Public Sub insertKIPHS()

'Establish the connection object
Call BeginConnection

'Establish the command object
Set cmdInsert = New ADODB.Command
cmdInsert.CommandType = adCmdStoredProc
cmdInsert.CommandText = "insert_kiphs"
cmdInsert.ActiveConnection = cnDatabase

'Establish the parameter objects
prInsert(0) = prInsert(0)
prInsert(1) = prInsert(1)
prInsert(2) = prInsert(2)
prInsert(3) = prInsert(3)
prInsert(4) = prInsert(4)
prInsert(5) = prInsert(5)
prInsert(6) = prInsert(6)
prInsert(7) = prInsert(7)

cmdInsert.Execute , prInsert


End Sub

Inserting Data From Text File Into A Access Table
Is there a easy way to take the data from a text file and intsert it into the proper fields of a table. I was gonna do it from within the database but I don't want to have to open the database to get it done. Anyone have a VB example on how to do this?

Thanks

Read File By Columns And Inserting Data Into Excel
Trying to export data from a txt file into a excel file.

* i have include a txt file which i am trying to read.

Have found lots of examples that will read line for line and even do some of them insert data into excel

However i have not been able to figure out how to read the txt file
by reading the first 31 lines as lines and inserting them into excel. and than from line 32 untill end of document reading the text in columns which are divided with a "|" and inserting that data into columns into the excel file.

examples i found reading a inserting text kinda look like this

Code:


Option Explicit

Private Sub Command1_Click()
Dim xl As Excel.Application
Dim wb As Excel.Workbook
Dim sheet As Excel.Worksheet
Dim x As Integer
Dim y As Integer
Dim lines() As String

Set xl = New Excel.Application
xl.Visible = True
Set wb = xl.Workbooks.Add
Set sheet = wb.Sheets("Sheet1")

lines = GetLines
For x = 0 To UBound(lines)
For y = 0 To Len(lines(x)) / 8
sheet1.Cells(x + 1, y + 1) = Mid$(lines(x), (y * 4) + 1, 4)
Next
Next

Set sheet = Nothing
Set wb = Nothing
Set xl = Nothing
End Sub

Private Function GetLines() As String()
Dim ff As Integer

ff = FreeFile
Open App.Path & "file.txt" For Input As #ff '
GetLines = Split(Input(LOF(ff), ff), vbNewLine)
Close #ff
End Function



Any help would be Very NICe

Excel File Download And Read/inserting Data To SQL Server
Hi all

My question here has two problems.

1. I have a form on a webpage, which i can fillup automatically and submit. In return it gives me a file to download. I want to download this file to some particular location. However I can not avoid the "save as" dialog using API as I do not have exact location of the and It is generated at runtime.

Code:
<form name="FORMNAME" action="actionpage" method="POST">

<input type="hidden" name="ExportToExcel" value="pagename.jsp">

<input type="hidden" name="FILE_ID" value="XXXXX">



<input type="hidden" name="STARTING_NUM" value="1">
<input type="hidden" name="ENDING_NUM" value="100000">


<input type="hidden" name="MAX_REC" value="100000">
</form>


This is pretty much the form code. there is an associated javascript which modifies the form data a little bit when its submitted. Infact this javascript submits the form.


Code:
<script language='JavaScript'>

function exportToExcel() {
var formName = document.forms['FORMNAME'];
var thisDate = new Date();
var targetName = "ExportToExcel" + thisDate.getTime();


var tempTarget = formName.target;
var tempAction = formName.action;

formName.action = "actionpage" + "?Time=" + thisDate.getTime();
formName.target = targetName;
formName.submit();


formName.action = tempAction;
formName.target = tempTarget;

</script>



2. I'm downloading files manually right now. However I need to read these files once they are downloaded. The data needs to be pushed into SQL servers. There maybe over 2-300 rows of data needing to be read and inserted in the database. As of now I'm storing the values in an array and inserting the same in database. I feel this is not the best way to do it. A batch insert will do better but I can not figure out correct way to do it.

Please help me out here. Let me know If you need extra info, I'll be glad to provide that.

Thanks in advance

VB 6.0 Code For Inserting An Iamge File Into DB [SQL 2000] As Image Data Type
Bhai log,
I have a proble.
I want to store Image in a SQL 2000 database as Image datatype, I would be gratefull to you if you can help me with VB Code or a SQL statement [Insert Query]



Regards,

Aditya Barve
adi_bar@rediffmail.com

Inserting Data From A Data Input Form In A Word Document
Hi

I have next to no knowledge of VB and have volunteered to create a template containing several input forms.

I have designed the forms in VBA (which include check boxes and combo box) but I have no idea how I’m going to get the data from the forms into the Word document.

For the form containing combo boxes, there could be several entries so I have 2 command buttons, one which should allow the user to add the contents of the combo boxes to a table in Word and then be able to add another entry to the table from the form. The other button should add the contents of the combo box to the table and close the form and open a new one.

I know I’m completely out of my depth here so any help would be greatly appreciated.

Thanks.



Edited by - julesl on 7/23/2003 3:38:57 AM

Inserting Data Into Word Document Using ADO Data Control
hi guys,
Iam trying to replace some of the text in my word document with the data present in the access tables.Iam using ADO data control for connectivity to the tables.But the problem is that iam unable to give the correct syntax in the "replacewith" field while replacing the current text.
Could some one plz help me out here?

Inserting Data In Access Using Do While Loop From A Data Grid
how to insert data in access using do while loop from a data grid



Edited by - manav74 on 10/30/2003 11:09:33 PM

Urgent: Please Help... This Is Regarding Data Grids And Inserting Data Into It
Hello All...

I'm in such a bit rut... i need anyone's help urgently... I'm working on this college project of a dental system that adds, edits, views and deletes information... i'm using ADO Connection and am facing a problem with filtering results in my datagrid...
when i startup the form... it gets all the data in the database according to the table that my datasource is set... now i want to filter the results according to the PatientID or Name criteria... this are my codes... could you please take a look at them and let me know what you think has gone wrong with it... i'm so dead if this isn't solved by tomorrow... Thank You So Much in Advance....

Public Sub FilterData(myId As String, SearchNum As Integer)
Dim SQLQuery As String
Dim rs As ADODB.Recordset

Set rs = New ADODB.Recordset

If SearchNum = 1 Then
SQLQuery = "SELECT PatientID, Name, IDNumber, DOB " _
& " FROM PersonalDetails " _
& " WHERE PatientID LIKE '" & myId & "'"
ElseIf SearchNum = 2 Then
SQLQuery = "SELECT PatientID, Name, IDNumber, DOB " _
& " FROM PersonalDetails " _
& " WHERE Name LIKE '" & myId & "'"
End If
rs.Open SQLQuery, DatabaseCon

With AdodcSearch
.ConnectionString = DatabaseCon
Set .Recordset = rs
End With

'I Think This Is Where The Trouble Begins
Set SearchGrid.DataSource = AdodcSearch
SearchGrid.Refresh

rs.Close
Set rs = Nothing
End Sub

Inserting Data Using SQL
I am trying to insert data into a table and can't seem to do it.

The database is Access 2000 and everthing I have read about SQL suggests the INSERT iNTO command which Access doesn't recognize.

I can select the records I want using the following code:

strSQL = "SELECT ContractNum, PmtStatus, CommissionStat, LastPmt "
strSQL = strSQL & "From tblContract"
strSQL = strSQL & " WHERE Month(LastPmt) = " & Month(dtpMonth.Value)
strSQL = strSQL & " AND year(LastPmt) = " & Year(dtpMonth.Value)
strSQL = strSQL & " AND (((IsDate(CommissionStat))=False)) AND (((IsDate(LastPmt))=True))"

adoCommission.RecordSource = strSQL
adoCommission.Refresh

When I try to add and use the UPDATE and SET it doesn't work. I have tried everything that I can think of to no avail.

Can anybody suggest an approach I can take or a source for information to help me solve this problem. I'm at my wits end.

Thanks

Inserting Data
I'm very new at VB.....

All I want to do it add values to column names, into one variant (called paramters) that I can feed to a function that will add these values to the appropriate columns in the database. Here's the script:

Dim pls_manager
Dim parameters
Dim RoleName
Dim security_token

Set pls_manager = CreateObject("PLS_Managers.PLSParameterMgr.1")

RoleName = "TestRole"

Set parameters = CreateObject( "ADODB.RecordSet" )
parameters.Fields.Append "PLS_SUBST_MARK", 16 'adTinyInt
parameters.Fields.Append "PLS_PRIORITY", 2 'adSmallInt
parameters.Fields.Append "PLS_LOWERLIMIT", 5 'adDouble
parameters.Fields.Append "PLS_UPPERLIMIT", 5 'adDouble
parameters.Fields.Append "PLS_TOLERANCE", 5 'adDouble
parameters.Fields.Append "PLS_USER_STATUS_MASK", 3 'adInteger
parameters.Fields.Append "PLS_STATUS_MASK", 3 'adInteger
parameters.Fields.Append "PLS_LIMITCHECK", 16 'adTinyInt
parameters.Fields.Append "PLS_GAPCHECK", 16 'adTinyInt
parameters.Fields.Append "PLS_STATUSCHECK", 16 'adTinyInt
' Fill record set with data
parameters.Open
parameters.AddNew
parameters.Fields( "PLS_SUBST_MARK" ).Value = 1
parameters.Fields( "PLS_PRIORITY" ).Value = 1
parameters.Fields( "PLS_LOWERLIMIT" ).Value = 1
parameters.Fields( "PLS_UPPERLIMIT" ).Value = 2
parameters.Fields( "PLS_TOLERANCE" ).Value = 1
parameters.Fields( "PLS_USER_STATUS_MASK" ).Value = 2
parameters.Fields( "PLS_STATUS_MASK" ).Value = 1
parameters.Fields( "PLS_LIMITCHECK" ).Value = 1
parameters.Fields( "PLS_GAPCHECK" ).Value = 1
parameters.Fields( "PLS_STATUSCHECK" ).Value = 1

pls_manager.Add_Role RoleName, 1, parameters

WScript.Echo "Script finished"


The error I get is "not a 2d array of variants (9 VT_DISPATCH)"

Thanks!

Help In Inserting Data Into Db !
When i try to insert data into db, a msgbox pop up n shows me this error:

Run-time error '-2147467259 (80004005)'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified.

and here is my code im trying to play with:


VB Code:
Private SQL As StringPrivate conDB As New ADODB.ConnectionPrivate myRS As New ADODB.Recordset Private Sub Command4_Click()     Dim CUSTINST As Integer    Dim strInput As String    Dim FileName As String    Dim AgreeNo As String    Dim ServNo As String    Dim FirstInst As String    Dim Interest As String    Dim Insurance As String    Dim LoanMonths As String    Dim Balance As String        CUSTINST = FreeFile()    Open "C:Documents and SettingskeenDesktopCUSTINST.txt" For Input As CUSTINST        While Not EOF(CUSTINST)            Line Input #CUSTINST, strInput             Set conDB = New ADODB.Connection            conDB.Open Connection1 'here's the problem encountered                       FileName = Mid$(strInput, 1, 10)            AgreeNo = Mid$(strInput, 11, 7)            ServNo = Mid$(strInput, 18, 7)            FirstInst = Mid$(strInput, 26, 5) & "." & Mid$(strInput, 32, 2)            Interest = Mid$(strInput, 34, 5) & "." & Mid$(strInput, 40, 2)            Insurance = Mid$(strInput, 42, 5) & "." & Mid$(strInput, 48, 2)            LoanMonths = Mid$(strInput, 50, 2)            Balance = Mid$(strInput, 52, 5) & "." & Mid$(strInput, 58, 2)                        List4.AddItem (FileName + " - " + AgreeNo + " - " + ServNo + " - " + FirstInst + " - " + Interest + " - " + Insurance + " - " + LoanMonths + " - " + Balance)                           SQL = "insert into dbo.PPP_Installment values ('" & AgreeNo & "', '" & ServNo & "', '" & FirstInst & "', '" & Interest & "', '" & Insurance & "', '" & LoanMonths & "', '" & Balance & "')"                        conDB.Execute SQL                    Wend    Close #CUSTINST End Sub


can anybody help me in this?

Inserting Data With ' In It Using Sql
When creating an SQL string to Insert or update.. or do anything with a record.. if you have a ' in the data as in

"SELECT * FROM table WHERE UserId = ' " & txtUserId & " ' "

if user id was "john's" then you get an error because of the ' in the ID.. it doesn't parse the SQL statement right because it thinks that the ' is where the string ends....

isn't there a way to use ' in your strings when dealing with SQL other than doubling it as '' ???? right now I have a function that replaces ' with '' in strings but you can't run it on the entire SQL statement.. only on the strings before you make the sql statement....

Inserting Data
Hi

Dim cl As Range
    
    For Each cl In [Sheet2!A1:C5]
        Worksheets("SHEET3").Cells(cl.Value, cl.Column) = "1"
    Next cl



here is the code I'm using right now and it works fine as you can see if sheet2 looks like this:

           A    
     1 5
     2 9     
     3 15
     4 33
     5 40
then the formula will insert a "1" in sheet3 cell A5,A9,A15,A33and A40 the problem is repetitive numbers
 if the A column looks like this


     A
1 1
2 4
3 1

then sheet 3 column A cell A1 should have a "2" and cell A4 would get "1"
the data is always 3 different numbers or 1 number and 2 repetitive numbers or
3 repetitive( in which case a "3" would be inserted


thanks for any help

lneilson
 









Edited by - lneilson on 1/16/2005 7:10:31 AM

Selecting And Inserting Data
Hi,

I need to display records from my database into a MSHFlexgrid and then select a row by highlighting it. Next, I will need to use the selected row of data and populate another form.

I have already managed to populate the MSHFlexgrid.
But:

Qn1) How do I highlight the selected row after I have double-clicked on it?

Qn2) How do I pass the selected record of data to the next form?

Can anyone help?

Thanks.

fAntAsy

Inserting Data Into Database
i am using access to build a DB
want the firt col in the db to be a unique key that
with every line i insert it grows in 1!

now : when i insert a new line into the db how can i get the
current new line number?
thanks in advance
peleg

Need Help With Inserting Data Into Sql Table
I have a form containing textboxes of txtID, txtSYSNAME, txtSYSTYPE, txtFREQ, txtPOP and a [Save] button to insert the data into an sql table.
The form also have a sqlconnection1, sqldataadapter1, and a generated dataset named WV2. The problem I'm having is that the following code does not perform an insert operation and it does not generate any errors. I'm new to vb.net, so any help is appreciated.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim p_idn, p_fq, p_pop As Int32
Dim p_name, p_type As String

p_idn = txtID.Text
p_name = "'" & Trim(txtSYSNAME.Text) & "'"
p_type = "'" & Trim(txtSYSTYPE.Text) & "'"
p_fq = Convert.ToInt32(txtFREQ.Text)
p_pop = Convert.ToInt32(txtPOP.Text)

SqlDataAdapter1.InsertCommand.CommandText = "INSERT INTO test (idnumber,sysname,systype,bacfreq,population) VALUES values (p_idn, p_name, p_type, p_fq, p_pop)"
SqlDataAdapter1.Update(WV21)

End Sub

Need Help Inserting Data From VB To MySQL
I have my connection established in the variable conn.

Ok, so I have this:


Code:
username = InputBox("User's username?", , "Username", 500, 500)
upassi = InputBox("User's password?", , "Password", 500, 500)
amt = InputBox("Amount user donated?", , "Amount Donated", 500, 500)

conn.Execute "INSERT INTO insiders VALUES (NULL, " + username + ", " + upassi +", " + amt)"
I know I HAVE to be doing something wrong b/c it says I have a syntax error. The thing I need help with is inserting these variables into the table. I have no problem doing this without using variables, but I'm not sure how to do it with variables

Any/all help will be most appreciated

Inserting Data Into The Database Through VB
Dear guyz, I really appreciate your help b4. However, I still have some confusions:

1. Let say I have 2 tables named tableA and tableB

tableA(Matrix Number, Student Name, Gender)
primary key: Matrix Number

tableB(ID Number, Matrix Number)
primary key: ID Number
foreign key: Matrix Number

My problem are:
- If I want to add new records from VB into the database, which one I must add first? tableA or tableB

- This is my coding to add the data. Plz correct me if Im wrong:

adotableA.Recordset.addNew
adotableA.Recordset.Fields("Matrix Number").Value = txtMatrixNum.text
adotableA.Recordset.Fields("Student Name").Value = txtStuName.text
..........
adotableA.Recordset.Update

adotableB.Recordset.Fields("ID Number").Value = txtIDNum.text
adotableB.Recordset.Fields("Matrix Number").Value = txtMatrixNum.text
adotableB.Recordset.Update
--------------------------------------------------------------------------

2. What is the difference(s) between using:

adotableB.Recordset.Fields(<field name>).Value and
adotableB.Recordset.Fields(<field name)

I have tried them both and both result the same
--------------------------------------------------------------------------

3. From if-else statement below, can I change them into select case statement?

If txtName.Text <> "" or txtName.Text <> "Mike" or txtID.Text <> "" or _

txtID.Text <> "#####" then
masgbox (bla..bla..bla)

end if

I have lot more questions, but I don't have enough time. Waiting for your reply soon. TQ so much

Inserting Data From Msflexgrid
i have 5 columns and many rows in msgrid rows are depend on data entry
it can be 10 or 15 or many columns are only 5 I want to insert grid data in sql table through
"insert into table" how should i write a insert statement so one by one row get inserted in a sql table

Collecting Data From One RTF Box And Inserting Into Another
My aim is to have the user input data into various rich text format boxes and then by clicking a command button for this text to be inserted into various places in an SQL paragraph in another RTF box.

e.g RTF_1 = results RTF_2 = 20

RTF_3 (SQL BOX) = show 'RTF_1'
where price = 'RTF_2'

the sql is incorrect here but this is just for ease of the example.

to an extent it works but it also inserts all of the font type and size etc, not just the text the user has entered. Does anyone know how to solve this problem?

Thanks!

Inserting Data Into Access DB
Hello,

I'm new to all the is VB lark, and any help will be welcome.

I have set up a form from which I hope to update a DB. I have 3 textboxes (Txt1, Text2, Text3). I want to insert date into a table with corresponding columns.

I've managed to connect to the DB using ADO, and return data to a list box from one column using a select statemen.

Can somebody point me in the right direction re: inserting data.

many thanks

Cbx

Inserting Data Into Access DB W/VB6
I am developing a program with VB6 that will log events to an Access DB file. The "INSERT INTO..." statement has a syntax error, but I can't figure out where the problem is. I'm fairly new to VB, so please forgive me if it's something stupid.

Thanks,
Chris


Code:
'Create the new database file.
Set cat = New ADOX.Catalog
cat.Create _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & AlarmLogFileName & ";"

' Create a new table.
Set tbl = New ADOX.Table
tbl.Name = AlarmLogTable
tbl.Columns.Append "Index", adInteger
tbl.Columns.Append "Date", adDate
tbl.Columns.Append "Time", adDate
tbl.Columns.Append "Description", adVarWChar, 255
cat.Tables.Append tbl

' Connect to the database.
Set con = cat.ActiveConnection

' Insert records.
con.Execute "INSERT INTO " & AlarmLogTable & " VALUES ('', " & _
"'" & Format(Now, "mmm dd, yyyy (dddd)") & "', '" & Time & "', " & AlarmText & " '')"

' Close the database connection.
con.Close
Set con = Nothing
Set tbl = Nothing
Set cat = Nothing

Inserting Data Into Table
im trying to add to a table, what is stored in an array, i thought id do as follows:

rs!ID = txtID.Text
rs!FName = array.Value(0)
rs!MName = Myarray.Value(1)
rs!LName = Myarray.Value(2)

but cuming up wiv error "Argument not optional" for ".Value"

any ideas???????

Inserting Data Into Outlook
Hi,
I need some help on the Outlook. As I was only a beginner on VB, so i was lost. Please Help me... Pls..... =)

I need to update info like contacts , calender retrieve from DB and update to the user's ms outlook.

I have to let the user access thru the Net so i was required to use ActiveX.
I can retrieve the data frm DB using ActiveX but i don't know how to update to the Outlook.

i know need to use Outlook.Application..... but i was helpless coz i don't know how to use....

so Can u help??
Really appreciate it... =)

Inserting Data Into MSACCESS
Im trying to insert data into access. The table im inserting into is linked to two other tables. I keep getting the following error

You cannot add or change a record because a related record is required in Skill

Basically i am using the following query

strQuery = "INSERT INTO ProductSkills ([SkillNo, SkillAvg]) VALUES ('"
strQuery = strQuery & Skills(iCount).SkillNo(iCount) & "," & Skills(iCount).EmployeeScore(iCount) & "')"

it must be something to do with the SkillNo being a primary key in the Skill table. How do i get round this.

The values im inserting into the PorductSkill for SkillNo match the values from the Skill table

VB Inserting Data Through A Form
I am inserting data through a form and after that the form should get refreshed. This is not happening. Any suggestions as to what i should be doing.

Thanks,
--Parag

Inserting Data And Going To New Form
hello:
My prob is that i have a Pkey which is an autonumber.

So when i insert values using a button, the value should be inserted and a new form should be refreshed, Now if the ID field( which is autonumber) is refreshed, it gives eror as it cant be null. WHat is the way that i can refresh it and get a new autoid.

Thanks,
--P

Help With Inserting Data Into A Database
I have a vb form with various text boxes and I wan't to be able to Insert the data within these text boxes into my table. The code below will insert constant values. However, I need to replace these values with variable names..Does anybody know
the correct cyntax....Please
'dbs.Execute " INSERT INTO tablename " & "(FirstName,LastName) VALUES " & "('Harry', 'Washington');"

Inserting Data Into An Access DB
I just created code for creating a new db and would like to fill the db with
data that I am extracting from a text file via textstream input. Does
anyone have a sample code thay would like to share for inputing data into an
Access Database? The versions I am running are VB 6.0 and Office 97.

Thank you ........

Kevin Baker
Client/Server Developer
Mutual of Enumclaw Insurance Co.
email@removed
(360)825-2591 x3471

Inserting A Data In A Blank Raw
Am trying to creat a hotel reservation project and i have created a table in access and this table has 40 maximum numbers. This table has Custname, RoomNumber, datein and dateout fields. Is there way i can use vb code so that if it reaches that dateout the name of the customer, datein and dateout gets deleted leaving RoomNo undeleted, and if i can just insert the name of the customer in a blank row.

i will be very greatfull if you help me

thanks

Inserting Data From VB To Excel
hallo,

please anybody give me a small example programm where in i insert values from VB into excel sheet.

i give values in VB example 3 textboxes and click ok

this ok should execute Excel sheet and overwrite these values in particulat cells

example.

cell D1 = Text1.text
cell H1 = Text2.text
cell R1 = Text3.text

how can we define this
Thanks in advance for ur help.

singoi


Text Box Value Is Not Inserting Into The Data
I am using vb 6.0 , ORACLE 8.1.7 & win 2000 in my home

I am trying to insert values in the table. following is the code I wrote
my form has 2 mask edit box for Phone & fax (and mask property is set to ####### (7), other are text boxes)

Code:
Private Sub cmd_frm_wing_profile_dd_Click()
' create a connection object
Dim oconn As New ADODB.Connection
oconn = "Provider=OraOLEDB.Oracle;" & _
           "Data Source=tps;" & _
           "User Id=system;" & _
           "Password=manager"
oconn.ConnectionString = oconn
oconn.Open
Dim qry As String

MsgBox "id " & txt_frmwp_wingid
MsgBox "prin " & txt_frmwp_principal
MsgBox "cont " & txt_frmwp_controller
MsgBox "email " & txt_frmwp_emailadd
MsgBox "ph " & msk_frmwp_phone
MsgBox "fax " & msk_frmwp_fax
MsgBox "name " & txt_frmwp_blockname
qry = "insert into wing (wing_id, principal_name, controller_name, email_add, phone_wing, fax_wing) values (' " & txt_frmwp_wing_id & " ' , ' " & txt_frmwp_blockname & " ' , ' " & txt_frmwp_principal & " ' , ' " & txt_frmwp_controller & " ' , ' " & msk_frmwp_phone & " ' , ' " & msk_frmwp_fax & " ')"

Dim inscom As New Command
With inscom
   .ActiveConnection = oconn
   .CommandType = adCmdText
   .CommandText = qry
   .Execute
End With
oconn.Close
End Sub


If I check the value of the txt_frmwp_wing_id at line shown in red it shows me the contents that I entered, but the when it comes to the line shown in blue it shows me that txt_frmwp_wing_id is empty.
how can I resolve this error
follwing is the structure of my table

Create table wing
( wing_id char(2),
   principal_name varchar2(40) not null,
   controller_name varchar2(40) not null,
   email_add varchar2(50),
phone_wing char(7) not null,
fax_wing char (7) not null,
wing_name varchar2(15),
constraint wing_wing_id_pk primary Key (wing_id)
)

Inserting Data Into Access
Hi all

I have a strange problem. I have a table in MS Access with 2 fields. I have bound this table to text fields in the form. Now the problem is if the table is empty, when I run the program and enter something in the textbox and press tab to go to the next textbox, whatever written in textbox1 disappears same with textbox2. But if there is even one row in table, then everything works fine. Did anybody get this type of problem. Any help is appreciated.

Regards

Inserting Data To Database
is it possible to insert the caption of an array of labels into an access db at the same time using Sql?

my code is:

[vb]
Dim cnCandidates As Connection

Private Sub cmdAdd_Click()
'add a new candidate

Dim stSql As String

Set cnCandidates = New Connection

With cnCandidates
.Provider = "Microsoft.Jet.OLEDB.4.0"
.ConnectionString = "A:Candidates.mdb"
.Open
End With

stSql = "INSERT into tblCandidate(Candidate_Name) " & _
" Values (lblName(0).caption)"

cnCandidates.Execute stSql

End Sub

[/vb]

Inserting Data In To List Box
how do i assign code to a specific field in a list box

eg if the list box is called listbox1 and there are 2 fields in the list box file1 and file2. I want to assign them to load a specific windows media file, so that when selected, only the play button is needed to start.

Inserting Data Into Database
I doing a project on online exam. There are two tables question table and subject table(Access database). In the subject table there are two fields sub_id and sub_name. In the question table there is sub_id field. In the dataentry screen there is a combo box of subject name. I want that while data entry when the user selects the subject name from the combobox the corresponding subject id should be entered in the question table.

I will be thankful if some one could suggest some code to solve the above query.

Inserting New Rows Of Data Into Excel From VB
Hi all - New to VB and am a bit stuck

A bit of background, I have set-up a VB form that is activated from a PowerPoint slide. The form allows a user to task using outlook, the thing is I want all the information from the form not only tasked to an individual, but also copied to Excel for recording.

Now I can get this to happen, but I cant figure out how to tell excel to insert a new line and then paste the data from my form into the applicable cells, also I am having trouble trying to get the Spreadsheet to save. The thing is the spreadsheet will need to be shared, so I want VB to Paste to the Spreadsheet, and then I want it to save so it can be opened by other users who will fill in the missing data.

I can get the data into Excel, but it keeps overwright the same line.

Hope you can help

Kon

Inserting Data From Userform Into Cells
Hi Guys,

I have made a little program that is reading data from the serial port into a textbox of my userform in excel, and now I need to insert the data in a cell of sheet1. How can I insert the data from my textbox into for example in cell B4??

Thanx!!!

Inserting Data Into Web Forms In A Vb Form
OK, basically, I have a form with a web browser in it. What I want to happen is this:

I want to enter a url, I want the web browser to go to the page, then I want to program the program so that it enters certain data into the forums on the webpage, then submit the details.

So far, I have the web browser, its goes to the url I want, I just don't know where to start when it comes to entering the data into the forms on the page, then simulating a person hitting the submit button.

Any suggestions?

all help appreciated.

Inserting Data Into Access From Vb6 (a Date)
i know your suposed to use # around the dates when inserting into access but its giving me an error and i cant figure out why. If I comment out the lines that are in bold it works fine so I know its has to be with the date, anyone see a problem?

strSql = "INSERT INTO DriverTracking "
strSql = strSql & "(DriverName"
strSql = strSql & ", DateTime"
strSql = strSql & ", Longitude"
strSql = strSql & ", Latitude"
strSql = strSql & ", City"
strSql = strSql & ", State"
strSql = strSql & ", TruckNumb"
strSql = strSql & ", TerminalNumber"
strSql = strSql & ", Division"
strSql = strSql & ") "
strSql = strSql & " VALUES ("
strSql = strSql & "'" & strTextName & "'"
strSql = strSql & ", #" & strTextDate & "#"
strSql = strSql & ", '" & strTextLongitude & "'"
strSql = strSql & ", '" & strTextLatitude & "'"
strSql = strSql & ", '" & strTextCity & "'"
strSql = strSql & ", '" & strTextState & "'"
strSql = strSql & ", '" & strTextTruckNumb & "'"
strSql = strSql & ", '" & strTextTermNumb & "'"
strSql = strSql & ", '" & strTextDivision & "'"
strSql = strSql & ")"
MsgBox strSql
my_Conn.Execute (strSql)

Prob In Inserting Data Into Table
Hi, i got a prob in inserting data into tbl, can anyone help me 2 debug my error?

mSQl = "SELECT FMNHDB_CALL_ASSIGNMENT.CALL_KEY, FMNHDB_CALL_ASSIGNMENT.DISTRICT, FMNHDB_CALL_ASSIGNMENT.RECEIVED_DATE, FMNHDB_CALL_ASSIGNMENT.COMPANY_NAME, FMNHDB_CALL_DETAIL1.CALLER_NAME, FMNHDB_CALL_DETAIL1.CALLER_PHONE, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_1, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_2, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_3, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_4, FMNHDB_CALL_DETAIL1.CUST_ADDRESS_5, FMNHDB_CALL_DETAIL2.PRODUCT_LINE, FMNHDB_CALL_ASSIGNMENT.ENG_REPAIR_TYPE FROM (FMNHDB_CALL_ASSIGNMENT INNER JOIN FMNHDB_CALL_DETAIL1 ON (FMNHDB_CALL_ASSIGNMENT.CALL_KEY = FMNHDB_CALL_DETAIL1.CALL_KEY) AND (FMNHDB_CALL_ASSIGNMENT.RECEIVED_DATE = FMNHDB_CALL_DETAIL1.RECEIVED_DATE)) INNER JOIN FMNHDB_CALL_DETAIL2 ON FMNHDB_CALL_ASSIGNMENT.CALL_KEY = FMNHDB_CALL_DETAIL2.CALL_KEY WHERE FMNHDB_CALL_ASSIGNMENT.ENG_A_OR_B_FLAG='A' and ("

DoCmd.RunSQL ("Insert Into Tbl_DataNeeded " & mSQl)"

Inserting Data Into Db Gives Run-time Error
Hi everyone,

I'm trying to insert a new record but I get this message:
Run-time error '-2147467259 (80004005)':
[Maximizer][ODBC Driver][Btrieve Database]
Related_To_Id+Related_To_Number (Client_Id+Contact_Number) NOT found in table COMPANY or PEOPLE (Rcode:431) (Ecode:-4458)

Through the messagebox, the query looks like this:
INSERT INTO Related_Entries (Related_To_Id,Related_To_Number,Related_From_Id,Related_From_Number," Desc") VALUES ('040603005910960349966C','0','040603005910960349966C','2','dealer');


What happens is that whatever Related_.._Id and Related_.._Number I use, there's an automatic check if the ID's exist in either the COMPANY or PEOPLE table.
This error sais it can't find it but the ID's shown in the string ARE correct.
I manually searched the DB and they're in there.

My guess is that the problem is located elsewhere.

Here is the code:


Code:
Dim strUpdate As String
strUpdate = "INSERT INTO Related_Entries (Related_To_Id," & _
"Related_To_Number,Related_From_Id," & _
"Related_From_Number,""Desc"") " & _
"VALUES ('" & objMaxRec.GetFieldValue("IDentification") & "'," & _
"" & objMaxRec.GetFieldValue("Contact_Number") & "," & _
"'" & dgContacts.Columns(3) & "'," & _
"" & dgContacts.Columns(4) & "," & _
"'" & relationType & "');"

MsgBox strUpdate

Dim updateConnection As New adodb.Connection
updateConnection.Open "DEMElocal", "MASTER", "cheers"
Dim updateCommand As adodb.Command
Set updateCommand = New adodb.Command
With updateCommand
.ActiveConnection = updateConnection
.CommandText = strUpdate
.CommandType = adCmdText
End With
updateCommand.Execute , , adExecuteNoRecords
Thanks a lot for your time,
Ruben

Copyright © 2005-08 www.BigResource.com, All rights reserved