-2
I have a postcode and divided into 2 variables: the first, where the first 4 numbers appear and the second where the last 3 appear.
Ex.:
4300-234 - first = 4300; second = 234.
I have a table in the database that has 3 columns referring to postal codes. A PC4
, where the first 4 numbers appear, the PC3
where the last 3 and the Desc
, where the corresponding description appears, that is, where these postal codes are from.
What I need is to compare my first variable with the column PC4
, compare the second variable to the column PC3
and then when my variables are equal to the columns PC4
and PC3
, I want to receive the corresponding data from the column DESC
.
But at what point do you want to do it? Num query right in the bank? Run a query by its C# code using some ORM or the
SqlCommand
? Please be more specific.– Jéf Bueno
I want to do this in code c#
– D C
It’s something I’ve never done, I’ve researched and I can’t figure out how to do
– D C
Okay, it’s okay that you don’t know, but at least try a little bit to explain to us how do you want to do that.
– Jéf Bueno
I tried to explain as best I could. I have 2 variables, variable1 has the first 4 numbers of the postal code, variable2 has the last 3. I need to compare variable1 with column PC4 and variable2 with PC3, when variable1 = PC4 and variable2 = PC3, I want to receive)
– D C
Let’s try again. Do you know how to connect to the database? Your project already connects to the database?
– Jéf Bueno
Yes, I have everything connected, I have already entered values in the database through the c# and everything.
– D C
Okay, we got to the part I wanted. How do you input (and read) database data?
– Jéf Bueno
through INSERT and SELECT
– D C
Okay, okay, let’s try it again. What you do select and Insert I know, after all there’s no other natural way to do it. Now, what I want to know is: what code you use to make a select in the database?
– Jéf Bueno
@Dc post the code, read this and rephrase the question https://answall.com/help/mcve, see that it is an official Help recommendation of the site and not mine. So you avoid your question being closed
– Guilherme Nascimento
@jbueno the problem is this ! do not know how to formulate my code to make a select !
– D C
@DC You already consult some data in the bank. Do not consult?
– Jéf Bueno
@jbueno The only thing I did in this project was to enter data in the database
– D C
And what code do you use to "enter data into the database"?
– Jéf Bueno
Conn. Open(); Com.Commandtext = "INSERT INTO Table(column1, column2, ...) VALUES (value1, value2, ...)"; Com.Executenonquery(); Conn.Close();
– D C