Click here to Skip to main content
15,913,669 members
Home / Discussions / Database
   

Database

 
GeneralRe: ADO + SQL statements Pin
Christian Graus22-Aug-04 15:19
protectorChristian Graus22-Aug-04 15:19 
GeneralRe: ADO + SQL statements Pin
#realJSOP22-Aug-04 23:35
professional#realJSOP22-Aug-04 23:35 
GeneralRe: ADO + SQL statements Pin
Christian Graus23-Aug-04 10:23
protectorChristian Graus23-Aug-04 10:23 
GeneralRe: ADO + SQL statements Pin
Ryan Roberts23-Aug-04 4:44
Ryan Roberts23-Aug-04 4:44 
GeneralRe: ADO + SQL statements Pin
J. Vorstenbosch25-Aug-04 0:40
J. Vorstenbosch25-Aug-04 0:40 
GeneralAuto date colum Pin
Zee_Zee21-Aug-04 1:55
Zee_Zee21-Aug-04 1:55 
GeneralRe: Auto date colum Pin
David Salter22-Aug-04 11:43
David Salter22-Aug-04 11:43 
GeneralSQL database problem Pin
Chodici Mrkev20-Aug-04 4:04
Chodici Mrkev20-Aug-04 4:04 
Hi all,
I have a problem. I have a database "Users", there are usernames, passwords, and other information, and I'm doing on the registration page - I want to be sure there will be no duplicity of usernames - I searched the old comments but it didn't help me, I have written this code:

Dim vilemConn As New SqlClient.SqlConnection
vilemConn.ConnectionString = "...."

'Here I set the Select command
Dim selectCMD As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT * FROM Users", vilemConn)

Dim vilemDA As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter
vilemDA.SelectCommand = selectCMD

Dim cb As SqlClient.SqlCommandBuilder = New SqlClient.SqlCommandBuilder(vilemDA)

vilemConn.Open()

Dim vilemDS As DataSet = New DataSet
vilemDA.Fill(vilemDS)

Dim vilemDR As DataRow = vilemDS.Tables(0).NewRow()
vilemDR("jmeno") = Server.HtmlEncode(txtJmeno.Text)
vilemDR("prijmeni") = Server.HtmlEncode(txtPrijmeni.Text)
vilemDR("trida") = Server.HtmlEncode(txtTrida.Text)
vilemDR("email") = Server.HtmlEncode(txtEmail.Text)
vilemDR("login") = Server.HtmlEncode(txtLogin.Text)
vilemDR("heslo") = Server.HtmlEncode(inputHeslo1.Value)
vilemDR("skin") = Server.HtmlEncode(dropdownSkin.SelectedValue)
vilemDR("image") = Server.HtmlEncode(txtImage.Text)
vilemDS.Tables(0).Rows.Add(vilemDR)

vilemDA.Update(vilemDS)
vilemDS.Reset()
vilemDA.Fill(vilemDS)

vilemConn.Close()

Although I don't know what SQL command I should use (and please send me all the syntax of it, with txtLogin.Text added, because I have problems with this - I am absolute beginner in SQL)
So I don't know what SQL command I should use, where should I place it and how to execute it, because I don't want to rewrite the Select command for later adding of the new record.

This is my experiment completed with msdn and this forums, either correct it or don't mind it, it doesn't work
'Nastavení příkazu SQL pro vyloučení duplicity
Dim NoDuplicityCMD As SqlClient.SqlCommand = New SqlClient.SqlCommand("SELECT COUNT(*) FROM Users WHERE login= " & txtLogin.Text, vilemConn)
'NoDuplicityCMD.CommandText = "SELECT COUNT(*) FROM Users WHERE login=@txtLogin.Text"
Dim a As Integer
a = NoDuplicityCMD.ExecuteNonQuery() 'is it good place to execute the query and should I write a= noduplicity... or only noduplicitycmd.executenonquery...
Response.Write(a)

Thanks very very much for your answers.
GeneralRe: SQL database problem Pin
Colin Angus Mackay20-Aug-04 4:49
Colin Angus Mackay20-Aug-04 4:49 
GeneralRe: SQL database problem Pin
Chodici Mrkev20-Aug-04 6:09
Chodici Mrkev20-Aug-04 6:09 
GeneralRe: SQL database problem Pin
Colin Angus Mackay20-Aug-04 6:26
Colin Angus Mackay20-Aug-04 6:26 
GeneralRe: SQL database problem Pin
Chodici Mrkev20-Aug-04 7:33
Chodici Mrkev20-Aug-04 7:33 
GeneralRe: SQL database problem Pin
Colin Angus Mackay20-Aug-04 7:54
Colin Angus Mackay20-Aug-04 7:54 
GeneralRe: SQL database problem Pin
Steven Campbell20-Aug-04 7:42
Steven Campbell20-Aug-04 7:42 
GeneralRe: SQL database problem Pin
Colin Angus Mackay20-Aug-04 7:55
Colin Angus Mackay20-Aug-04 7:55 
GeneralRe: SQL database problem Pin
Christian Graus22-Aug-04 15:30
protectorChristian Graus22-Aug-04 15:30 
GeneralRe: SQL database problem Pin
Colin Angus Mackay23-Aug-04 4:12
Colin Angus Mackay23-Aug-04 4:12 
GeneralEnterprise level database access in C#/.net Pin
Salil Khedkar19-Aug-04 21:36
Salil Khedkar19-Aug-04 21:36 
GeneralRe: Enterprise level database access in C#/.net Pin
Christian Graus22-Aug-04 15:27
protectorChristian Graus22-Aug-04 15:27 
GeneralDisplaying a DataGrid in child Form Pin
abhishk2001@yahoo.com19-Aug-04 13:01
abhishk2001@yahoo.com19-Aug-04 13:01 
GeneralAssembly resource not found Pin
unosinu19-Aug-04 6:00
unosinu19-Aug-04 6:00 
GeneralRe: Assembly resource not found Pin
Mekong River21-Aug-04 4:57
Mekong River21-Aug-04 4:57 
GeneralSQL query with parameter and % Pin
YomYom19-Aug-04 4:58
YomYom19-Aug-04 4:58 
GeneralRe: SQL query with parameter and % Pin
Chris Meech19-Aug-04 8:29
Chris Meech19-Aug-04 8:29 
GeneralRe: SQL query with parameter and % Pin
YomYom19-Aug-04 10:23
YomYom19-Aug-04 10:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.