12 Replies - 1183 Views - Last Post: 19 July 2012 - 07:03 AM Rate Topic: ***** 1 Votes

#1 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Problem With Saving textboxes data

Posted 18 July 2012 - 09:00 PM

I have made an application in which there r several textboxes and command buttons.
and when we press save button, the textboxes data get saved in access database.

when i enter normal text in the textbox, it is working.

but when i enter the below data in the textbox, the following error is displayed.

Data:

FILENAME INP "/dso/dsocln/ehco/medical/raw-input/ehco_bcne_cabc_F20120101_T20120331_vall.txt_94283";



Data all;



INFILE INP
END = EOF
RECFM = v
LRECL = 760
TRUNCOVER
;
input
@170 DateofBirth $CHAR10. /* Date of Birth */




;



output all;



run;







proc freq data = all;



tables DateofBirth / list missing;



title'DateofBirth';



run;


Error:

Syntax error (missing operator) in query expression ''FILENAME INP "/dso/dsocln/ehco/medical/raw-input/ehco_bcne_cabc_F20120101_T20120331_vall.txt_94283";

Can you please help me solving this error?
thanks in advance...

Is This A Good Question/Topic? 0
  • +

Replies To: Problem With Saving textboxes data

#2 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 09:24 PM

Means i am saying when i manually enter the data in one of the textboxes. Ans presses the save button, Then the data gets saved.

But if i copy the data from some outer source and paste the data in the Textbox. And now when i try to save the data, the above error generates.

The data which i pasted into the textbox is also mentioned in my prevoius thread.

Please help.
Was This Post Helpful? 0
  • +
  • -

#3 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 09:45 PM

Properly Defined:

When i enter this data in the textbox:

title'DateofBirth';

and try to save the data

the error generates:

Syntax error (missing operator) in query expression ''title'DateofBirth';''.

This post has been edited by abhishek415: 18 July 2012 - 09:47 PM

Was This Post Helpful? 0
  • +
  • -

#4 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 10:12 PM

My code for saving textbox data is:

Dim dbPath As String = "C:\Users\Abhishek\Documents\ToolDatabase.mdb"
 Dim connStr As String ="Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source=" & dbPath & ";Jet OLEDB:Database Password=agupt80;"
 Using connection As New OleDb.OleDbConnection(connStr)

            Dim cmd As New OleDb.OleDbCommand
            Dim trans As OleDb.OleDbTransaction

            If (connection.State = ConnectionState.Closed) Then

                connection.Open() 'Open connection to database
            End If
            cmd.Connection = connection
            trans = connection.BeginTransaction(IsolationLevel.ReadCommitted)

            cmd.Transaction = trans

Dim b As String = Me.TextBox2.Text
            If (b = "") Then
                b = "None"
            End If

cmd.CommandText = "insert into Table1 values('" & b & "')"

                cmd.ExecuteNonQuery() 'Execute command
                trans.Commit()
 End Using


This post has been edited by abhishek415: 18 July 2012 - 10:12 PM

Was This Post Helpful? 0
  • +
  • -

#5 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 11:04 PM

Try with parameters. Always use parameters.
Was This Post Helpful? 0
  • +
  • -

#6 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 11:08 PM

I also did that. But thats too not working...
My code is:

Dim dbPath As String = "C:\Users\Abhishek\Documents\ToolDatabase.mdb"
 Dim connStr As String ="Provider=Microsoft.Jet.OLEDB.4.0;" _
        & "Data Source=" & dbPath & ";Jet OLEDB:Database Password=agupt80;"
 Using connection As New OleDb.OleDbConnection(connStr)

            Dim cmd As New OleDb.OleDbCommand
            Dim trans As OleDb.OleDbTransaction

            If (connection.State = ConnectionState.Closed) Then

                connection.Open() 'Open connection to database
            End If
            cmd.Connection = connection
            trans = connection.BeginTransaction(IsolationLevel.ReadCommitted)

            cmd.Transaction = trans

Dim b As String = Me.TextBox2.Text
            If (b = "") Then
                b = "None"
            End If

cmd.CommandText = "insert into Table1 values('" & b & "')"
With cmd
                    .Parameters.AddWithValue("Description", Me.TextBox2.Text)

                    .ExecuteNonQuery() 'Execute command
                End With
                
                trans.Commit()
 End Using



Was This Post Helpful? 0
  • +
  • -

#7 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Problem With Saving textboxes data

Posted 18 July 2012 - 11:11 PM

If you use parameters then you must include them in the query.
cmd.CommandText = "INSERT INTO Table1 VALUES(@Description)"

Was This Post Helpful? 0
  • +
  • -

#8 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 12:03 AM

cmd.CommandText = "insert into Table1(@Description) values ("'Me.Textbox2.text'")"
With cmd
     .Parameters.AddWithValue("@Description", Me.TextBox2.Text)

     .ExecuteNonQuery() 'Execute command
End With


Now it is saying Sysntax error in Insert Command.

This post has been edited by abhishek415: 19 July 2012 - 12:03 AM

Was This Post Helpful? 0
  • +
  • -

#9 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 12:11 AM

this is your code:
cmd.CommandText = "insert into Table1(@Description) values ("'Me.Textbox2.text'")"

and this is what I said how it should looks:
cmd.CommandText = "INSERT INTO Table1 VALUES(@Description)"

or
cmd.CommandText = "INSERT INTO Table1 ("Here goes the field name where you want to put value") VALUES(@Description)"

Was This Post Helpful? 2
  • +
  • -

#10 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 12:14 AM

My field name in access 2003 is Description where i want to put the value of TextBox2.

Now can u tell me the Syntax?
Was This Post Helpful? -1
  • +
  • -

#11 sela007  Icon User is offline

  • D.I.C Addict

Reputation: 138
  • View blog
  • Posts: 840
  • Joined: 21-December 11

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 12:22 AM

cmd.CommandText = "INSERT INTO Table1 (Description) VALUES(@Description)"


Was This Post Helpful? 2
  • +
  • -

#12 abhishek415  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 30-June 12

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 12:31 AM

Thank You Sela007
It really Worked.
Hats Off...!! :)
God Bless You...!!
Was This Post Helpful? 0
  • +
  • -

#13 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5581
  • View blog
  • Posts: 11,934
  • Joined: 02-June 10

Re: Problem With Saving textboxes data

Posted 19 July 2012 - 07:03 AM

Who the frak do you think you are?! Do not ever PM someone and attempt to hand out assignments like this again!

The people here are volunteers, not your employees. You do not write them and tell them to "solve the problem" and "sort it out" like you are their boss.

You also need to consider that you are on an American website from a foreign country: We aren't in your same time zone. You wrote this in the middle of the night USA time. Nobody wants to wake up to this.

I don't give a frak what kind of jam you got yourself into, you have to be patient and let the experts in each area have time to look at the questions posted over night and decide for themselves which ones they choose to answer and which ones they are qualified to answer. You had NO REASON to start spamming experts, begging for help with a question you had just posted. Obviously the volunteer system works because sela007 was able to help you out - before I even woke up I might add.

Just remember you are one of 500,000 members of this board. The last thing we need is to have everyone thinking as you do, that they are somehow special and more important than everyone else so they can send out messages telling others to help them. I do not need to wake up to 10,000 pleas for help every morning.

Attached Image

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1