Hi,
Am trying to connect and insert a record into my database using vb.net this is my code: - cs = New SqlConnection("Data Source=AYACHMOHAMED;Initial Catalog=Employe;Integrated Security=True")
-
-
cs.Open()
-
sqlcom = New SqlCommand("INSERT INTO EMPLOYE VALUES 3, 'AYACH', 'PDG'", cs)
-
Try
-
ra = sqlcom.ExecuteNonQuery()
-
Catch ex As Exception
-
MsgBox("wrong " & ra)
-
End Try
-
cs.Close()
the problem is ra = 0 mean no insertion made I can't figure it out!
thank's in advance
Assuming that your table is actually named EMPLOYE and not EMPLOYEE. And assuming your connection string cs is correctly formatted. And assuming your data source AYACHMOHAMED is properly set up.
If that really is the entire SQL string you tried to use, then that is also incorrect. - sqlcom = New SqlCommand("INSERT INTO EMPLOYE (ActualFieldNameOfIntegerField, ActualFieldNameOfStringField, ActualFieldNameOfOtherStringField) VALUES (3, 'AYACH', 'PDG')", cs)
7 1907
Your insert syntax is incorrect.
OK how about this one: - sqlcom = New SqlCommand("INSERT INTO EMPLOYE (field1, field2...) VALUES (value1, value2, ...)", cs)
guess what doesn't work either
Assuming that your table is actually named EMPLOYE and not EMPLOYEE. And assuming your connection string cs is correctly formatted. And assuming your data source AYACHMOHAMED is properly set up.
If that really is the entire SQL string you tried to use, then that is also incorrect. - sqlcom = New SqlCommand("INSERT INTO EMPLOYE (ActualFieldNameOfIntegerField, ActualFieldNameOfStringField, ActualFieldNameOfOtherStringField) VALUES (3, 'AYACH', 'PDG')", cs)
concerning the EMPLOYE is the french version of EMPLOYEE for the rest all of it is ok and guess what I know that there is something wrong with it and this is why I posted the question are you realy trying to help here or just piling up your postes...?
I'm trying to help but if you really used - INSERT INTO EMPLOYE (field1, field2...) VALUES (value1, value2, ...)
as your SQL string, of course it's going to fail. You didn't specify the field names or the values to use. You basically copied and pasted the syntax from a SQL help file.
So either, A) that is not the actual SQL string you used in your code, in which case we can't help you without seeing the actual string you used or B) that is the actual string you used.
If B, then you either didn't read the rest of the help file or you didn't understand it. So, assuming you did read it, but the text was confusing, I gave you the correct SQL string to use from the minimal information that was provided.
Which was - sqlcom = New SqlCommand("INSERT INTO EMPLOYE (ActualFieldNameOfIntegerField, ActualFieldNameOfStringField, ActualFieldNameOfOtherStringField) VALUES (3, 'AYACH', 'PDG')", cs)
All you had to do was replace some of what I had with your field names. However, judging by your most recent post, you did not try my suggestion.
you didn't even remember my first post you are such a lost cause...! it's realy pitty there was a time when we realy havn't to argue about things like these and when people were realy truly engaged on this site...
thx anyway
Your first post had no field names and your first post had incorrect SQL syntax. You looked up the correct syntax, but you didn't replace the values in the syntax with the values that were relevant to your tables. So you ended up with incorrect syntax again. So I gave you the correct syntax in which all you had to to was plug in your field names. But you didn't do that. At no point did you give me all the relevant information that is needed for syntactically correct SQL. Nor did you give the impression that you even tried.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: george |
last post by:
This is like the bug from hell. It is kind of hard to explain, so
please bear with me.
Background Info: SQL Server 7.0, on an NT box, Active Server pages
with Javascript, using ADO objects.
...
|
by: Mike |
last post by:
I am trying to use the 'Bulk Insert' command to load a data file into a
MS-SQL db. The line I am using is:
Bulk Insert SVC_Details From "C:\XFILE.TXT" With (FieldTerminator = ',')
I have tried...
|
by: Ed |
last post by:
Hi,
I want to load data to a table in Sql Server from a
dataset table in my vb.net app using a dataAdapter. I
know how to do this as follows (my question is to see if I
can reduce the amount...
|
by: Rob Dob |
last post by:
How do I create a insert command that will take a datatable or datarow as a
parameter instead of me having to supply it with parameters for each field
value. I heard something about using the v2.0...
|
by: mabond |
last post by:
Hi
VB.NET 2005 Express edition
Microsoft Access 2000 (SP-3)
Having trouble writing an "insert into" command for a Microsoft table I'm
accessing through oledb.
I've tried to follow the same...
|
by: Iwan Petrow |
last post by:
Hi,
I do this - take some data with sqldataadaptor (at this moment
2000rows) in fill datatable.
For each two rows do some calculations and save data to the database
with insert command.
(the...
|
by: iKiLL |
last post by:
Hi all
I am having problems getting my SqlCeDataAdapter to Update the SQL Mobile
Data base.
i am using C# CF2.
I have tried this a number of different ways. Starting with the command
builder...
|
by: Randy |
last post by:
I think that this is a really simple question. I have a table adapter
set up with the various sql queries. I'd like to allow the user to
make changes to a given row on a form. Each of the...
|
by: Freedolen |
last post by:
Hi,
I have checked with some sample data and found inserting of data using 'insert command' takes more time than using 'load data' command to load data from another file. What is the process...
|
by: Lawrence Pereira |
last post by:
Can any one help me in inserting any date into the table using insert command
because when i m trying to insert date using insert command the query executes but the date is totally wrong if i am...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |